//============================================================== public void hystWinClosed(object sender, System.EventArgs e) { currentMode = SAVE_USTANOVKI; Hysteresys_cfg s = sender as Hysteresys_cfg; double a = s.hystValue; send_udp(currentMode, (byte)(a * 10)); }
//============================================================================================= private void bg_WorkerReport(object sender, ProgressChangedEventArgs e) { byte [] receiveBytes = e.UserState as byte[]; if (receiveBytes != null) { switch (receiveBytes[0]) { case READ_WEEK_CONFIGS_ANS: pbWait.Visibility = Visibility.Hidden; nRespTimer.Stop(); cfgTitle.Content = "Неделя"; for (int i = 0; i < 7; i++) { day[i] = receiveBytes[i + 1]; } for (int i = 0; i < 7; i++) { string path = "/TermoWifi;component/drawable/"; if (day[i] == 'H') { path += "beer.png"; } else { path += "shovel.png"; } items.Add(new User() { PicTime = path, Time = weekDays[i] }); } break; case READ_DAY_CONFIGS_ANS: nRespTimer.Stop(); int pNumb = receiveBytes[1] & 0x0f; int pCount = receiveBytes[2]; byte param = Convert.ToByte((receiveBytes[1] & 0x0f) + 1); pbWait.Value = (100 / pCount) * pNumb; if (hDayCfg) { param |= (byte)0x80; } if (hDayCfg) { cfgTitle.Content = "Выходные"; } else { cfgTitle.Content = "Будни"; } string h = "", m = ""; if (receiveBytes[3] < 10) { h = "0"; } if (receiveBytes[4] < 10) { m = "0"; } items.Add(new User() { number = pNumb.ToString(), // + " of " + pCount, PicTime = "/TermoWifi;component/drawable/timeicon.png", Time = h + receiveBytes[3] + ":" + m + receiveBytes[4], PicTemp = "/TermoWifi;component/drawable/tempicon.png", Temp = (String.Format("{0,4:N1}", (float)BitConverter.ToInt16(new byte[2] { receiveBytes[5], receiveBytes[6] }, 0) / 10)) }); if (pNumb < pCount) { send_udp(READ_DAY_CONFIGS, param); } else { btnAdd.Visibility = Visibility.Visible; pbWait.Visibility = Visibility.Hidden; } break; case READ_USTANOVKI_ANS: nRespTimer.Stop(); pbWait.Visibility = Visibility.Hidden; Hysteresys_cfg hystWin = new Hysteresys_cfg((float)((float)receiveBytes[1] / 10)); hystWin.Closed += hystWinClosed; hystWin.ShowDialog(); break; case OK_ANS: switch (currentMode) { case SAVE_WEEK_CONFIGS: case SAVE_USTANOVKI: bSave.Visibility = Visibility.Hidden; pbWait.Visibility = Visibility.Hidden; nRespTimer.Stop(); break; case SAVE_DAY_CONFIGS: if (currentPeroid < items.Count) { pbWait.Value = (100 / items.Count) * currentPeroid; currentPeroid++; formBuffer(SAVE_DAY_CONFIGS); send_udp(currentMode, 0); } else { bSave.Visibility = Visibility.Hidden; //.setVisibility(View.GONE); pbWait.Visibility = Visibility.Hidden; //.setVisibility(View.INVISIBLE); nRespTimer.Stop(); } break; } break; case BAD_ANS: break; } } }