Beispiel #1
0
Frame::Frame(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
	WxPanel1 = new wxPanel(this, -1, wxPoint(-5, 9), wxSize(360, 83));
	(void) new wxStaticText(WxPanel1, -1, wxT("IP Adress:"), wxPoint(9, 0), wxDefaultSize);
	(void) new wxStaticText(WxPanel1, -1, wxT("Port:"), wxPoint(231, 0), wxDefaultSize);
	(void) new wxStaticText(WxPanel1, -1, wxT("Tibia Version:"), wxPoint(288, 0));
	wxArrayString arrayStringFor_ip;
	vector<string>z;
	z = h.getHistory();
	for(int i = 0; i < int(z.size()); i++){
		wxString wxs(z[i].c_str(), wxConvUTF8);
		arrayStringFor_ip.Add(wxs);
	}
	ip = new wxComboBox(WxPanel1, -1, wxT(""), wxPoint(11, 17), wxSize(214, 21), arrayStringFor_ip);
	wxArrayString arrayStringFor_clients;
	arrayStringFor_clients.Add(wxT("Auto"));
	for(int i = 0; i < int(sizeof(adresses)/sizeof(adresses[0])); i++){
        wxString wxs(adresses[i][0].insert(1, ".").c_str(), wxConvUTF8);
        arrayStringFor_clients.Add(wxs);
    }
	host = new wxSpinCtrl(WxPanel1, wxID_ANY, wxT("7171"), wxPoint(232, 17), wxSize(55, 21), wxSP_ARROW_KEYS, 1000, 9999, 7171);
    clients = new wxComboBox(WxPanel1, -1, wxT("Auto"), wxPoint(289, 17), wxSize(54, 21), arrayStringFor_clients, wxCB_READONLY);
	(void) new wxButton(WxPanel1, BUTTON_CHANGE_IP, wxT("Change IP"), wxPoint(81, 40), wxSize(87, 31));
    Connect(BUTTON_CHANGE_IP, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Frame::FrameClickEvents));
	(void) new wxButton(WxPanel1, BUTTON_ADD_TO_TRAY, wxT("Add to Tray"), wxPoint(170, 40), wxSize(87, 31));
	(void) new wxButton(WxPanel1, wxID_EXIT, wxT("Exit"), wxPoint(259, 40), wxSize(87, 31));
	sb = new wxStatusBar(this, -1);

	wxMenuBar *menubar = new wxMenuBar();
	wxMenu *file = new wxMenu;
	file->Append(MENU_CLEAR_HISTORY, wxT("Clear History"));
	file->AppendSeparator(); 
	file->Append(wxID_EXIT, wxT("Exit"));
	menubar->Append(file, wxT("File"));
	wxMenu *help = new wxMenu;
	help->Append(MENU_INFO, wxT("Info"));
	menubar->Append(help, wxT("Help"));
	SetMenuBar(menubar);
    trayIcon = new TrayIcon(this);
    wxIcon icon(Self_Frame_XPM);
	if(!trayIcon->SetIcon(icon, wxT("IP Changer")))
        wxMessageBox(wxT("Could not set icon."));
	SetStatusBar(sb);
	SetTitle(wxT("IP Changer"));
	SetIcon(Self_Frame_XPM);
	SetSize(8,8,362,147);
	Center();
}
Beispiel #2
0
wxString CMgString::GetWxStr( _MGSTRID id )
{
    if (ZH_CN_UTF_8 == m_Lang || 
	EN_US_UTF_8 == m_Lang || 
	ZH_TW_UTF_8 == m_Lang || 
	DE_DE_UTF_8 == m_Lang ||
	PT_BR_UTF_8 == m_Lang)
    {
        wxString wxs( m_SA[ m_Lang ][ id ].c_str(), wxConvLocal ); 
        return wxs;
    }
    else if ( ZH_CN_18030 == m_Lang )
    {
        //Converts from UTF-8 encoding to Unicode
        wchar_t bufuc[ 512 ];
        wxMBConvUTF8 conv;
        int len = conv.MB2WC( bufuc, m_SA[ ZH_CN_UTF_8 ][ id ].c_str(), 512 );
        //wxCSConv tomb(wxT("zh_CN.GB18030"));
        wxCSConv tomb( wxT( "cp936" ) );
        char bufmb[ 512 ];
        len = tomb.WC2MB( bufmb, bufuc, 512 );
        wxString wxs = wxString ( bufmb, wxConvLocal ); //unicode patch
        return wxs;
    }
    else if ( ZH_TW_BIG5 == m_Lang )
    {
        //Converts from UTF-8 encoding to Unicode
        wchar_t bufuc[ 512 ];
        wxMBConvUTF8 conv;
        int len = conv.MB2WC( bufuc, m_SA[ ZH_TW_UTF_8 ][ id ].c_str(), 512 );
        //wxCSConv tomb(wxT("zh_CN.GB18030"));
        wxCSConv tomb( wxT( "cp950" ) );
        char bufmb[ 512 ];
        len = tomb.WC2MB( bufmb, bufuc, 512 );
        std::string str( bufmb );
        //return str;
	return wxString(str.c_str(),wxConvLocal);	
    }


    //other lang goes here
    return _( "no lang" );
}
Beispiel #3
0
void guiChangeIP(Frame *frame, int eventId){
    Change c;
    HANDLE tibia = c.getTibiaProcess();
    if(!tibia){
        frame->sb->SetStatusText(wxT("Tibia process not found!"),0);
        if(eventId == MENU_CHANGE_IP)
            sendDialog(wxT("Tibia process not found!"), wxOK | wxICON_ERROR);
        CloseHandle(tibia);
        return;
    }
    std::string sip = std::string(frame->ip->GetValue().mb_str());
    int sport = frame->host->GetValue();
    std::string client = std::string(frame->clients->GetValue().mb_str());
    if(sip == ""){
        frame->sb->SetStatusText(wxT("IP adress not found!"),0);
        if(eventId == MENU_CHANGE_IP)
        	sendDialog(wxT("IP adress not found!"), wxOK | wxICON_ERROR);
        return;
    }
    size_t found = sip.find(":");
    if(found != string::npos){
        sport = atoi(sip.substr(found+1, sip.size()).c_str());
        sip = sip.substr(0, found);
        frame->ip->SetValue(sip);
        frame->host->SetValue(sport);
    }
        
    if(client != "Auto"){
        std::string s ="";
        s += client.at(1);
        if(s == ".")
        	client = client.erase(1,1);
    }
        	
    bool ret = c.changeIP(sip, sport, client);
        
    if(ret){
        frame->sb->SetStatusText(wxT("IP Changed!"),0);
        if(eventId == MENU_CHANGE_IP)
        	sendDialog(wxT("IP Changed!"), wxOK);
    }else{
        frame->sb->SetStatusText(wxT("IP not Changed!"),0);
        if(eventId == MENU_CHANGE_IP)
        	sendDialog(wxT("IP not Changed!"), wxOK | wxICON_ERROR);
        return;
    }
    
    char buf[4];
    itoa(sport, buf, 10);
    std::string save;
    save += sip + ":" + buf;
	h.saveHistory(save);
	frame->ip->Clear();
	vector<string>z;
	z = h.getHistory();
	for(int i = 0; i < int(z.size()); i++){
		wxString wxs(z[i].c_str(), wxConvUTF8);
		frame->ip->Append(wxs);
	}
	std::string tmp = z[0].substr(0, z[0].size()-5);
	wxString last(tmp.c_str(), wxConvUTF8);
	frame->ip->SetValue(last);
}