コード例 #1
0
        private void Startup()
        {
            Ares.Controllers.UIThreadDispatcher.Dispatcher   = this;
            Ares.Controllers.Messages.Instance.MessageAdded += new EventHandler <Controllers.MessageEventArgs>(MessageAdded);
            AresSettings.ReadFromConfigFile();

            m_ServerSearch              = new Controllers.ServerSearch(Settings.Settings.Instance.UdpPort + 1);
            m_ServerSearch.ServerFound += new EventHandler <Controllers.ServerEventArgs>(m_ServerSearch_ServerFound);
            m_ServerSearch.StartSearch();

            m_Network = new FromControllerNetwork(this);
            if (Settings.Settings.Instance.IPAddress.Length == 0)
            {
                System.Net.IPAddress[] addresses = System.Net.Dns.GetHostAddresses(String.Empty);
                if (addresses.Length > 0)
                {
                    Settings.Settings.Instance.IPAddress = addresses[0].ToString();
                }
            }
            m_Network.InitConnectionData();
            m_Network.StartUdpBroadcast();

            broadCastTimer          = new System.Timers.Timer(500);
            broadCastTimer.Elapsed += new System.Timers.ElapsedEventHandler(broadCastTimer_Tick);
            broadCastTimer.Enabled  = true;
            m_Network.ListenForClient();

            MaybeStartPlayer();
        }
コード例 #2
0
ファイル: SettingsDialog.cs プロジェクト: zBart/Ares
        public SettingsDialog()
        {
            InitializeComponent();
            AresSettings.ReadFromConfigFile();
            Settings.Settings settings = Settings.Settings.Instance;
            projectFileBox.Text = settings.RecentFiles.GetFiles().Count > 0 ? settings.RecentFiles.GetFiles()[0].FilePath : "";
            playerPathBox.Text  = FindLocalPlayer();
            musicFilesBox.Text  = settings.MusicDirectory;
            soundFilesBox.Text  = settings.SoundDirectory;
            tcpPortUpDown.Value = settings.TcpPort;
            udpPortUpDown.Value = settings.UdpPort;
            bool foundAddress   = false;
            bool foundV4Address = false;
            int  v4AddressIndex = 0;

            foreach (System.Net.IPAddress address in System.Net.Dns.GetHostAddresses(String.Empty))
            {
                if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    foundV4Address = true;
                    v4AddressIndex = ipAddressBox.Items.Count;
                }
                String s = address.ToString();
                ipAddressBox.Items.Add(s);
                if (s.Equals(settings.IPAddress))
                {
                    foundAddress = true;
                }
            }
            if (foundAddress)
            {
                ipAddressBox.SelectedItem = settings.IPAddress;
            }
            else if (ipAddressBox.Items.Count > 0)
            {
                ipAddressBox.SelectedIndex = foundV4Address ? v4AddressIndex : 0;
                settings.IPAddress         = ipAddressBox.SelectedItem.ToString();
            }
            else
            {
                ipAddressBox.Enabled = false;
            }
        }