public void Send(CMiXData datacontext, FrameworkElement uielement) { if (datacontext != null) { List <string> propdata = new List <string>(); PropertyInfo property = datacontext.GetType().GetProperty("Channel" + uielement.Name); Type type = property.PropertyType; var list = property.GetValue(datacontext, null); if (type == typeof(ObservableCollection <string>)) { foreach (string st in (ObservableCollection <string>)list) { propdata.Add(st); } Sender.Send(new OscMessage("/" + "Channel" + uielement.Name, propdata.ToArray())); } else if (type == typeof(ObservableCollection <bool>)) { foreach (bool st in (ObservableCollection <bool>)list) { propdata.Add(st.ToString()); } Sender.Send(new OscMessage("/" + "Channel" + uielement.Name, propdata.ToArray())); } else if (type == typeof(ObservableCollection <double>)) { foreach (double st in (ObservableCollection <double>)list) { propdata.Add(st.ToString()); } Sender.Send(new OscMessage("/" + "Channel" + uielement.Name, propdata.ToArray())); } else if (type == typeof(ObservableCollection <Color>)) { foreach (Color col in (ObservableCollection <Color>)list) { var drawingcolor = System.Drawing.Color.FromArgb(col.A, col.R, col.G, col.B); string hex = "#" + Utils.ColorToHexString(col); propdata.Add(hex); } Sender.Send(new OscMessage("/" + "Channel" + uielement.Name, propdata.ToArray())); } else if (type == typeof(ObservableCollection <ObservableCollection <ListBoxFileName> >)) { List <string> count = new List <string>(); foreach (ObservableCollection <ListBoxFileName> fn in (ObservableCollection <ObservableCollection <ListBoxFileName> >)list) { int i = 0; foreach (ListBoxFileName lb in (ObservableCollection <ListBoxFileName>)fn) { if (lb.FileIsSelected == true) { i += 1; propdata.Add(lb.FileName); } } count.Add(i.ToString()); } List <OscMessage> messagelist = new List <OscMessage> { new OscMessage("/" + "Channel" + uielement.Name, propdata.ToArray()), new OscMessage("/" + "Channel" + uielement.Name + "Count", count.ToArray()) }; OscBundle bundle = new OscBundle(1, messagelist.ToArray()); Sender.Send(bundle); } } }
private void New_Click(object sender, RoutedEventArgs e) { EnabledOSC = false; DataContext = new CMiXData(); EnabledOSC = true; }