コード例 #1
0
 private void backgroundWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         MessageBox.Show("Thread cancelled.");
     }
     else if (e.Error != null)
     {
         MessageBox.Show(e.Error.Message, "An Error Occurred");
     }
     else
     {
         if (Tool.IsOnline)
         {
             this.Close();
             Tool.IsInit        = true;
             MyTitle.Visibility = Visibility.Collapsed;
             Tool.SaveIPXml();
         }
         else
         {
             MyTitle.Visibility = Visibility.Visible;
             //MyTitle.Background =new  SolidColorBrush(Colors.Red);
             Tool.IsInit        = false;
             MyTitle.Text       = "连接失败:" + strRes;
             ConnectBtn.Content = "重试";
         }
         MainContent.IsEnabled = true;
         Close.IsEnabled       = true;
         PLC_IP.Focus();
     }
 }
コード例 #2
0
        private void SerialiseIP(PLC_IP iP)
        {
            XmlSerializer formatter = new XmlSerializer(typeof(PLC_IP));

            // получаем поток, куда будем записывать сериализованный объект
            using (FileStream fs = new FileStream("ip.xml", FileMode.OpenOrCreate))
            {
                formatter.Serialize(fs, iP);
            }
        }
コード例 #3
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         PLC_IP newIP = new PLC_IP(Convert.ToInt32(IP_192.Text), Convert.ToInt32(IP_168.Text), Convert.ToInt32(IP_1.Text), Convert.ToInt32(IP_17.Text));
         SerialiseIP(newIP);
         iP = newIP;
         temperature_K1.IP = iP;
         temperature_P1.IP = iP;
         wetness.IP        = iP;
         flaw.IP           = iP;
         perepad.IP        = iP;
     }
     catch (Exception ex) { }
 }
コード例 #4
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         PLC_IP newIP = new PLC_IP(Convert.ToInt32(IP_192.Text), Convert.ToInt32(IP_168.Text), Convert.ToInt32(IP_1.Text), Convert.ToInt32(IP_17.Text));
         SerialiseIP(newIP);
         iP              = newIP;
         temperature.IP  = iP;
         pressure.IP     = iP;
         conductivity.IP = iP;
         flaw.IP         = iP;
         level.IP        = iP;
         cO2.IP          = iP;
     }
     catch (Exception ex) { }
 }
コード例 #5
0
        private void DeserialiseIP()
        {
            XmlSerializer formatter = new XmlSerializer(typeof(PLC_IP));

            try
            {
                using (FileStream fs = new FileStream("ip.xml", FileMode.OpenOrCreate))
                {
                    PLC_IP newIP = (PLC_IP)formatter.Deserialize(fs);
                    if (newIP.IP_192 != 0)
                    {
                        iP          = newIP;
                        IP_192.Text = iP.IP_192.ToString();
                        IP_168.Text = iP.IP_168.ToString();
                        IP_1.Text   = iP.IP_1.ToString();
                        IP_17.Text  = iP.IP_17.ToString();
                    }
                }
            }
            catch (Exception ex) { }
        }
コード例 #6
0
        public MainWindow()
        {
            InitializeComponent();
            Dictionary <GrafType, GrafSet> grafSets = new Dictionary <GrafType, GrafSet>();

            InitializeSets(grafSets);
            temperature_K1 = new GrafPage(grafSets[GrafType.Temp_K1]);
            wetness        = new GrafPage(grafSets[GrafType.Wetness]);
            temperature_P1 = new GrafPage(grafSets[GrafType.Temp_P1]);
            flaw           = new GrafPage(grafSets[GrafType.FlawAir]);
            perepad        = new GrafPage(grafSets[GrafType.Perepad]);
            iP             = new PLC_IP(192, 168, 1, 18);
            DeserialiseIP();
            temperature_K1.IP = iP;
            wetness.IP        = iP;
            temperature_P1.IP = iP;
            flaw.IP           = iP;
            perepad.IP        = iP;

            Main.Content = temperature_K1;
        }
コード例 #7
0
 public BeginWindow()
 {
     InitializeComponent();
     backgroundWorker = (BackgroundWorker)this.FindResource("backgroundWorker");
     UIExpand();
     PLC_IP.Focus();
     this.PreviewMouseLeftButtonDown += (sender, e) =>
     {
         if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
         {
             this.ResizeMode = ResizeMode.NoResize;
         }
     };
     this.PreviewMouseLeftButtonUp += (sender, e) =>
     {
         if (this.ResizeMode == ResizeMode.NoResize)
         {
             this.ResizeMode = ResizeMode.CanResize;
         }
     };
     Tool.OpenIPXml();
     PLC_IP.Text = Tool.CPUIP;
 }
コード例 #8
0
        public MainWindow()
        {
            InitializeComponent();
            Dictionary <GrafType, GrafSet> grafSets = new Dictionary <GrafType, GrafSet>();

            //temperature1 = new Temperature1();
            InitializeSets(grafSets);
            temperature  = new GrafPage(grafSets[GrafType.Temp]);
            pressure     = new GrafPage(grafSets[GrafType.Pressure]);
            conductivity = new GrafPage(grafSets[GrafType.Conductivity]);
            flaw         = new GrafPage(grafSets[GrafType.Flaw]);
            level        = new GrafPage(grafSets[GrafType.Level]);
            cO2          = new GrafPage(grafSets[GrafType.CO2]);
            iP           = new PLC_IP(192, 168, 1, 18);
            DeserialiseIP();
            temperature.IP  = iP;
            pressure.IP     = iP;
            conductivity.IP = iP;
            flaw.IP         = iP;
            level.IP        = iP;
            cO2.IP          = iP;

            Main.Content = temperature;
        }