コード例 #1
0
ファイル: Main.cs プロジェクト: pengpercy/lphant
        public CMain(string[] args)
        {
            m_Preferences = new Config(Application.StartupPath, "configInterface.xml", "0.01", "lphantInterface");
            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 eLePhantForm(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 eLePhantForm(m_elink, m_Mutex, CRemoto.interfazremota));
                        }
                        else
                        {
                            MessageBox.Show("Can not connect with the host specified in preferences", "lphant", 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
ファイル: Main.cs プロジェクト: sonicwang1989/lphant
        public CMain(string[] args)
        {
            m_Preferences = new Config(Application.StartupPath, "configInterface.xml", "0.01", "lphantInterface");
            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 eLePhantForm(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 eLePhantForm(m_elink,m_Mutex,CRemoto.interfazremota));
                        }
                        else
                        {
                            MessageBox.Show("Can not connect with the host specified in preferences","lphant",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();
            }
        }
コード例 #3
0
ファイル: StartForm.cs プロジェクト: pengpercy/lphant
        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))
                {
                    eLePhant.Client.eLePhantForm FormeLePhant = new eLePhantForm(m_elink, m_Mutex, CRemoto.interfazremota);
                    FormeLePhant.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Can not connect or invalid password", "lphant remote connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (this.IniciarLocal.Checked)
            {
                eLePhant.Client.eLePhantForm FormeLePhant = new eLePhantForm(m_elink, m_Mutex);
                this.Hide();
                FormeLePhant.Show();
            }
        }
コード例 #4
0
ファイル: StartForm.cs プロジェクト: sonicwang1989/lphant
        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))
                {
                    eLePhant.Client.eLePhantForm FormeLePhant=new eLePhantForm(m_elink,m_Mutex,CRemoto.interfazremota);
                    FormeLePhant.Show();
                    this.Hide();
                }
                else
                    MessageBox.Show("Can not connect or invalid password","lphant remote connection",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
            if (this.IniciarLocal.Checked)
            {
                eLePhant.Client.eLePhantForm FormeLePhant=new eLePhantForm(m_elink,m_Mutex);
                this.Hide();
                FormeLePhant.Show();
            }
        }