コード例 #1
0
ファイル: OscCommands.cs プロジェクト: vincenthamm/ATF
 public OscCommands(
     ICommandService commandService,
     OscService oscService)
 {
     CommandService = commandService;
     OscService = oscService;
 }
コード例 #2
0
ファイル: OscDialog.cs プロジェクト: BeRo1985/LevelEditor
        public OscDialog(OscService oscService, OscCommandReceiver commandReceiver)
        {
            InitializeComponent();
            SuspendLayout();

            m_oscService = oscService;
            m_commandReceiver = commandReceiver;

            string myHostName;
            try
            {
                myHostName = Dns.GetHostName();
            }
            catch (SocketException)
            {
                myHostName = "<not available>";
            }
            m_hostName.Text = myHostName;

            int localIPAddressIndex = 0;
            int selectedIndex = 0;
            foreach (IPAddress receivingIPAddress in OscService.GetLocalIPAddresses())
            {
                m_receivingIPAddresses.Items.Add(receivingIPAddress.ToString());
                if (receivingIPAddress.Equals(m_oscService.ReceivingIPAddress))
                    selectedIndex = localIPAddressIndex;
                localIPAddressIndex++;
            }
            m_receivingIPAddresses.SelectedIndex = selectedIndex;

            m_receivingPortNumber.Text = m_oscService.ReceivingPort.ToString(CultureInfo.InvariantCulture);
            m_statusTextBox.Text = m_oscService.StatusMessage;

            m_destinationIPAddress.Text = m_oscService.DestinationEndpoint.Address.ToString();
            m_destinationPortNumber.Text = m_oscService.DestinationEndpoint.Port.ToString(CultureInfo.InvariantCulture);

            var addressInfos = new List<OscService.OscAddressInfo>(m_oscService.AddressInfos);
            addressInfos.Sort((info1, info2) => info1.Address.CompareTo(info2.Address));

            ListView.ListViewItemCollection items = m_listView.Items;
            foreach (OscService.OscAddressInfo info in addressInfos)
            {
                var item = new ListViewItem(new string[] {
                    info.Address,
                    info.PropertyName,
                    PropertyTypeToReadableString(info.PropertyType),
                    info.CompatibleType.ToString()
                });
                items.Add(item);
            }

            // Add commands
            if (m_commandReceiver != null)
            {
                foreach (string address in m_commandReceiver.GetOscAddresses())
                {
                    var item = new ListViewItem(new string[]
                    {
                        address,
                        "n/a",
                        "n/a",
                        "n/a"
                    });
                    items.Add(item);
                }
            }

            ResumeLayout();
        }