public CMain(string[] args) { m_Preferences = new Config(Application.StartupPath, "configInterface.xml", "0.01", "HathiInterface"); m_Preferences.LoadProperties(); if (args.Length>0) m_elink=args[0]; //bool noInstanceRuning; //m_Mutex=new Mutex(true,InterfaceConstants.GUID,out noInstanceRuning); m_Mutex=new Mutex(true,InterfaceConstants.GUID); //if (noInstanceRuning) if (m_Mutex.WaitOne(0,true)) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnAppDomainException); if (m_Preferences.GetBool("StartupLocal",true)) { Application.Run(new HathiForm(m_elink,m_Mutex)); } else if (m_Preferences.GetBool("StartupRemote",false)) { string remoteIP=m_Preferences.GetString("RemoteIP",""); int remotePort=m_Preferences.GetInt("RemotePort",0); string remotePass=m_Preferences.GetString("RemotePassword",""); if ((remotePort>0)&&(remoteIP.Length>0)&&(remotePass.Length>0)) { CedonkeyCRemote cRemote=new CedonkeyCRemote(); if (cRemote.Connect(remoteIP,remotePass,remotePort)) { Application.Run(new HathiForm(m_elink,m_Mutex,cRemote.remoteInterface)); } else { MessageBox.Show("Can not connect with the host specified in preferences","Hathi",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); Application.Run(new StartForm(m_elink,m_Mutex)); } } else Application.Run(new StartForm(m_elink,m_Mutex)); } else Application.Run(new StartForm(m_elink,m_Mutex)); } else { NotifyToMainInstance(); } }
private void Accept_OnClick(object sender, System.EventArgs e) { string IP=RemoteIP.Text + "." + RemoteIP02.Text + "." + RemoteIP03.Text + "." + RemoteIP04.Text; if (this.RemoteConnector.Checked) { if (cRemote==null) cRemote=new CedonkeyCRemote(); int RemotePort; if (this.RemotePort.Text=="") RemotePort=4670; else RemotePort=System.Convert.ToInt32(this.RemotePort.Text); cRemote.DisConnect(); if (cRemote.Connect(IP,pw.Text,RemotePort)) { Hathi.UI.Winform.HathiForm FormHathi=new HathiForm(m_elink,m_Mutex,cRemote.remoteInterface); FormHathi.Show(); this.Hide(); } else MessageBox.Show("Can not connect or invalid password","Hathi remote connection",MessageBoxButtons.OK,MessageBoxIcon.Error); } if (this.HathiLocal.Checked) { Hathi.UI.Winform.HathiForm FormHathi=new HathiForm(m_elink,m_Mutex); this.Hide(); FormHathi.Show(); } }