Exemplo n.º 1
0
 private void right_aux_Click(object sender, MouseButtonEventArgs e)
 {
     if (IsAdapterOnFirst())
     {
         if (devicesPanel.Children.Count > 32)
         {
             MessageBox.Show("模块不能超过32个");
             return;
         }
         DeviceDialog DD = new DeviceDialog(devicesPanel.Children.Count);
         DD.Title = string.Format("自定义添加 {0}", (sender as DeviceButtonAsAuxiliary).Code.Content.ToString());
         DD.ShowDialog();
         Console.WriteLine("{0},{1}", DD.pos, DD.c**t);
         if (DD.pos != 0 && DD.c**t != 0)
         {
             for (int i = 0; i < DD.c**t; i++)
             {
                 DeviceButtonAsAuxiliary aux = (sender as DeviceButtonAsAuxiliary).Clone();
                 aux.MouseRightButtonUp += new MouseButtonEventHandler(remove_single_Click);
                 devicesPanel.Children.Insert(DD.pos + i, aux);
                 SurplusPower += Convert.ToInt32(aux.Power.Content);
                 PowerCheck();
             }
         }
         return;
     }
     MessageBox.Show("请先装配适配器");
 }
 public DeviceButtonAsAuxiliary Clone()
 {
     DeviceButtonAsAuxiliary aux = new DeviceButtonAsAuxiliary();
     aux.Code.Content = this.Code.Content;
     aux.Tag1.Content = this.Tag1.Content;
     aux.Tag2.Content = this.Tag2.Content;
     aux.Tag3.Content = this.Tag3.Content;
     aux.Tag4.Content = this.Tag4.Content;
     aux.Tag5.Content = this.Tag5.Content;
     aux.DevicePower = this.DevicePower;
     aux.Power.Content = this.Power.Content;
     return aux;
 }
 public DeviceButtonAsAuxiliary AsAux()
 {
     DeviceButtonAsAuxiliary dev = new DeviceButtonAsAuxiliary();
     dev.Code.Content = this.Code;
     dev.Tag1.Content = this.Tag1;
     dev.Tag2.Content = this.Tag2;
     dev.Tag3.Content = this.Tag3;
     dev.Tag4.Content = this.Tag4;
     dev.Tag5.Content = this.Tag5;
     dev.DevicePower = this.Power;
     dev.Power.Content = this.Power.ToString();
     return dev;
 }
Exemplo n.º 4
0
        public DeviceButtonAsAuxiliary Clone()
        {
            DeviceButtonAsAuxiliary aux = new DeviceButtonAsAuxiliary();

            aux.Code.Content  = this.Code.Content;
            aux.Tag1.Content  = this.Tag1.Content;
            aux.Tag2.Content  = this.Tag2.Content;
            aux.Tag3.Content  = this.Tag3.Content;
            aux.Tag4.Content  = this.Tag4.Content;
            aux.Tag5.Content  = this.Tag5.Content;
            aux.DevicePower   = this.DevicePower;
            aux.Power.Content = this.Power.Content;
            return(aux);
        }
        public DeviceButtonAsAuxiliary AsAux()
        {
            DeviceButtonAsAuxiliary dev = new DeviceButtonAsAuxiliary();

            dev.Code.Content  = this.Code;
            dev.Tag1.Content  = this.Tag1;
            dev.Tag2.Content  = this.Tag2;
            dev.Tag3.Content  = this.Tag3;
            dev.Tag4.Content  = this.Tag4;
            dev.Tag5.Content  = this.Tag5;
            dev.DevicePower   = this.Power;
            dev.Power.Content = this.Power.ToString();
            return(dev);
        }
Exemplo n.º 6
0
 private void add_aux_Click(object sender, RoutedEventArgs e)
 {
     if (IsAdapterOnFirst())
     {
         if (devicesPanel.Children.Count > 32)
         {
             MessageBox.Show("模块不能超过32个");
             return;
         }
         DeviceButtonAsAuxiliary aux = (sender as DeviceButtonAsAuxiliary).Clone();
         aux.MouseRightButtonUp += new MouseButtonEventHandler(remove_single_Click);
         devicesPanel.Children.Add(aux);
         SurplusPower += Convert.ToInt32(aux.Power.Content);
         PowerCheck();
         return;
     }
     MessageBox.Show("请先装配适配器");
 }
Exemplo n.º 7
0
        public MainWindow()
        {
            InitializeComponent();

            DeviceNumberBoxOfAdapter adpNum = new DeviceNumberBoxOfAdapter();

            numPanel.Children.Add(adpNum);

            for (int i = 0; i < 32; i++)
            {
                DeviceNumberBoxOfModule modNum = new DeviceNumberBoxOfModule();
                modNum.Content = string.Format("[ {0} ]", i + 1);
                numPanel.Children.Add(modNum);
            }



            this.label.SetBinding(Label.ContentProperty, new Binding("SurplusPower")
            {
                Source = this, Path = new PropertyPath("SurplusPower")
            });

            XElement root = XElement.Load(fileName);

            var devicesQuery =
                from device in root.Elements("Device")
                select device;

            foreach (var dev in devicesQuery)
            {
                DeviceButtonFactory btn = new DeviceButtonFactory();
                btn.Code  = dev.Element("Code").Value.ToString();
                btn.Tag1  = dev.Element("Tags").Attribute("tag1").Value;
                btn.Tag2  = dev.Element("Tags").Attribute("tag2").Value;
                btn.Tag3  = dev.Element("Tags").Attribute("tag3").Value;
                btn.Tag4  = dev.Element("Tags").Attribute("tag4").Value;
                btn.Tag5  = dev.Element("Tags").Attribute("tag5").Value;
                btn.Power = Convert.ToInt32(dev.Element("OutCurrent").Value) - Convert.ToInt32(dev.Element("InCurrent").Value);


                switch (dev.Element("Type").Value)
                {
                case "adapter":
                    DeviceButtonAsAdapter adp = btn.AsAdapter();
                    adp.Margin = new Thickness(5, 0, 0, 0);
                    adp.Click += new RoutedEventHandler(add_adp_Click);
                    this.adapterPanel.Children.Add(adp);
                    break;

                case "IO":
                    DeviceButtonAsIO IO = btn.AsIO();
                    IO.Margin              = new Thickness(5, 0, 0, 0);
                    IO.Click              += new RoutedEventHandler(add_IO_Click);
                    IO.MouseRightButtonUp += new  MouseButtonEventHandler(right_IO_Click);
                    this.IOPanel.Children.Add(IO);
                    break;

                case "function":
                    DeviceButtonAsFunction fun = btn.AsFun();
                    fun.Margin              = new Thickness(5, 0, 0, 0);
                    fun.Click              += new RoutedEventHandler(add_fun_Click);
                    fun.MouseRightButtonUp += new MouseButtonEventHandler(right_fun_Click);
                    this.functionPanel.Children.Add(fun);
                    break;

                case "auxiliary":
                    DeviceButtonAsAuxiliary aux = btn.AsAux();
                    aux.Margin              = new Thickness(5, 0, 0, 0);
                    aux.Click              += new RoutedEventHandler(add_aux_Click);
                    aux.MouseRightButtonUp += new MouseButtonEventHandler(right_aux_Click);
                    this.auxiliaryPanel.Children.Add(aux);
                    break;

                default:
                    break;
                }
            }
        }