예제 #1
0
파일: Main.cs 프로젝트: biuken/eAnt
        public CMain(string[] args)
        {
            m_Preferences = new Config(Application.StartupPath, "configInterface.xml", "0.01", "AntInterface");
            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 eAntForm(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))
                    {
                        CedonkeyCRemoto CRemoto = new CedonkeyCRemoto();
                        if (CRemoto.Connect(remoteIP, remotePass, remotePort))
                        {
                            Application.Run(new eAntForm(m_elink, m_Mutex, CRemoto.interfazremota));
                        }
                        else
                        {
                            MessageBox.Show("Can not connect with the host specified in preferences", "Ant", 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();
            }
        }
예제 #2
0
파일: StartForm.cs 프로젝트: biuken/eAnt
        private void Accept_OnClick(object sender, System.EventArgs e)
        {
            string IP = IPRemota1.Text + "." + IPRemota2.Text + "." + IPRemota3.Text + "." + IPRemota4.Text;

            if (this.ConectarRemoto.Checked)
            {
                if (CRemoto == null)
                {
                    CRemoto = new CedonkeyCRemoto();
                }

                int puertor;
                if (this.PuertoR.Text == "")
                {
                    puertor = 4670;
                }
                else
                {
                    puertor = System.Convert.ToInt32(this.PuertoR.Text);
                }

                CRemoto.DisConnect();
                if (CRemoto.Connect(IP, pw.Text, puertor))
                {
                    eAnt.Client.eAntForm FormeAnt = new eAntForm(m_elink, m_Mutex, CRemoto.interfazremota);
                    FormeAnt.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Can not connect or invalid password", "Ant remote connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (this.IniciarLocal.Checked)
            {
                eAnt.Client.eAntForm FormeAnt = new eAntForm(m_elink, m_Mutex);
                this.Hide();
                FormeAnt.Show();
            }
        }