Esempio n. 1
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("please select upload type");
                return;
            }

            clsRegistry reg = new clsRegistry();

            m_baseGuid = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "Guid");
            if (reg.strRegError != null)
            {
                m_baseGuid = Guid.NewGuid().ToString();
                reg.SetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "Guid", m_baseGuid);
            }
            string guid = m_client.GetClientGuid();

            NetCard.NetCard n      = new NetCard.NetCard();
            string          baseIp = n.getComputerIP();

            if (baseIp == "0.0.0.0")
            {
                string bip = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Base", "IpAddress");
                if (reg.strRegError == null)
                {
                    baseIp = bip;
                }
                else
                {
                    MessageBox.Show("You need to specify the base ip address in the registry");
                    return;
                }
            }

            if (checkBox1.Checked == true)
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    try
                    {
                        Dictionary <string, string> storageDirectoryDic = new Dictionary <string, string>();
                        storageDirectoryDic.Add(guid, textBox3.Text);
                        GojiWCFStreamingBase.StartStorageServer(storageDirectoryDic);


                        if (SetCopyTimerEvent() == false)
                        {
                            return;
                        }
                        m_client.AddDateToUploadTargetFolder(checkBox8.Checked);
                        m_client.ConnectToStreamingServer(baseIp, textBox4.Text, textBox5.Text);
                        button14.Enabled = true;
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
                else if (comboBox1.SelectedIndex == 1)
                {
                    try
                    {
                        string s = m_client.InitializeDropBox();
                        if (s != "ok")
                        {
                            MessageBox.Show(s);
                        }
                        else
                        {
                            m_client.StartDropBoxUploadMode(true);
                            button14.Enabled = true;
                        }
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
                else if (comboBox1.SelectedIndex == 2)
                {
                    m_client.StartTCPStreamingServer(1024 * 1024 * 30, 5005);
                    m_client.OpenTCPStreamingClient(baseIp, textBox4.Text, textBox5.Text);
                }
                checkBox1.ForeColor = System.Drawing.Color.Green;
            }
            else
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    m_client.CloseCopyThread();
                    while (m_client.IsCopyThreadIsAlive() == true)
                    {
                        Application.DoEvents();
                        Thread.Sleep(1000);
                    }
                }
                else
                {
                    try
                    {
                        m_client.StartDropBoxUploadMode(false);
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
                checkBox1.ForeColor = System.Drawing.Color.Red;
            }
        }