public MainWindow() { InitializeComponent(); //功能模块数标签内容绑定SurplusPower依赖属性 this.modulecount.SetBinding(Label.ContentProperty, new Binding("ModuleCount") { Source = this, Path = new PropertyPath("ModuleCount") }); //剩余功率标签内容绑定SurplusPower依赖属性 //this.label.SetBinding(Label.ContentProperty, new Binding("SurplusPower") { Source = this, Path = new PropertyPath("SurplusPower") }); XElement root = XElement.Load(fileName); //创建设备查询 var deviceQuery = from device in root.Elements().Elements("Device") select device; //实例一个标签 TabItemOfDevices TD = new TabItemOfDevices(); //循环引用查询 foreach (var dev in deviceQuery) { ButtonOfDevice btn = new ButtonOfDevice(dev); btn.Click += new RoutedEventHandler(add_dev_Click); if (btn.Tag1.Content.ToString() != "适配器" && btn.Tag1.Content.ToString() != "终端模块") { btn.MouseRightButtonUp += new MouseButtonEventHandler(right_mod_Click); } TD.SP.Children.Add(btn); if (dev.NextNode == null) { TD.Header = dev.Parent.Attribute("name").Value; this.TC.Items.Add(TD); TD = new TabItemOfDevices(); } } }
public ButtonOfDevice Clone() { ButtonOfDevice nbtn = new ButtonOfDevice(); //nbtn.usercontrol.Width = this.usercontrol.Width; nbtn.Width = this.Width; nbtn.grid.Width = this.grid.Width; nbtn.Code.Width = this.Code.Width; nbtn.Tag1.Width = this.Tag1.Width; nbtn.Tag2.Width = this.Tag2.Width; nbtn.Tag3.Width = this.Tag3.Width; nbtn.Tag4.Width = this.Tag4.Width; nbtn.Tag5.Width = this.Tag5.Width; nbtn.Power.Width = this.Power.Width; nbtn.line2.X2 = this.line2.X2; nbtn.line3.X1 = this.line3.X1; nbtn.line3.X2 = this.line3.X2; nbtn.line1.Stroke = this.line1.Stroke; nbtn.line2.Stroke = this.line2.Stroke; nbtn.line3.Stroke = this.line3.Stroke; nbtn.line1.StrokeThickness = this.line1.StrokeThickness; nbtn.line2.StrokeThickness = this.line2.StrokeThickness; nbtn.line3.StrokeThickness = this.line3.StrokeThickness; nbtn.Code.Background = this.Code.Background; nbtn.Code.Content = this.Code.Content; nbtn.Tag1.Content = this.Tag1.Content; nbtn.Tag2.Content = this.Tag2.Content; nbtn.Tag3.Content = this.Tag3.Content; nbtn.Tag4.Content = this.Tag4.Content; nbtn.Tag5.Content = this.Tag5.Content; nbtn.Power.Content = this.Power.Content; if (Convert.ToInt32(nbtn.Power.Content.ToString()) > 0) { } return nbtn; }