private void CmdAdd_HandleExecute() { IWidgetInfo widgetInfo = null; foreach (var wInfo in WidgetInfos) { if (wInfo.Value.IsWidget(CurrentEquipmentType)) { widgetInfo = wInfo.Value; } } if (widgetInfo != null) { for (int i = 0; i < currentAmount2Add; i++) { Equipment eq = new Equipment() { WidgetAddresses = new AddressCollection() { ChannelDescriptions = widgetInfo.ChannelDescriptions, Addresses = new List<int>(Enumerable.Repeat<int>(0, widgetInfo.ChannelDescriptions.Count)) }, WidgetNamespace = widgetInfo.WidgetNamespace }; WrpEquipment wrpEq = new WrpEquipment(eq); ListEquipments.Add(wrpEq); listEquipmentsOriginal.Add(eq); } } else { Log.Error("Could not find equipment to remove - are all namespaces correct in IWidgetInfo.instances?"); } }
public void OnImportsSatisfied() { // TODO: get via WCF ListEquipments = new List<Equipment>(); ListEquipments.Add(new Equipment() { WidgetNamespace = "FHVGame.Light.MH.X25.Client.Controls", WidgetAddresses = new AddressCollection() { Addresses = new List<int>() { 1, 2, 3 , 4 , 5 } } }); //ListEquipments.Add(new Equipment() { WidgetClientNamespace = "Bakk2.Widget.PAR.Stairville64.Client", WidgetAddresses = new List<AddressBase>() { new AddrDmx(4), new AddressBase(5), new AddressBase(6) } }); //DirectoryCatalog dc = new DirectoryCatalog(@"..\..\..\Repo"); //CompositionContainer cc = new CompositionContainer(dc); try { //cc.ComposeParts(this); var firstControl = WidgetControls.FirstOrDefault(); Equipment[] vv = new Equipment[0]; foreach (var control in WidgetControls) { var eqs = ListEquipments.Where(x => control.GetType().Namespace.Equals(x.WidgetNamespace)).ToArray(); for (int i = 0; i < eqs.Length; i++) { IPult tmp = control.CreateInstance(eqs[i].WidgetAddresses); // Set addresses for UI-Element //tmp.SetAddresses(eqs[i].WidgetAddresses); // Add to UI Expander ex = new Expander(); ex.Content = tmp; stackPanelWidgets.Children.Add(ex); } } //stackPanelWidgets.Children.Add((UIElement)WidgetControls.FirstOrDefault()); try { //cc.ComposeParts(((UserControl)WidgetControls.FirstOrDefault()).DataContext); } catch (Exception e) { Console.WriteLine(e); } stackPanelWidgets.Children.Add(new Label() { Content = "Ein Test aus dem Code" }); } catch (Exception e) { Console.WriteLine(e); } }
public WrpEquipment(Equipment equipment) { Equipment = equipment; Addresses = new WrpAddressCollection(equipment.WidgetAddresses); }