WinTest.xaml.cs 24.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
using RCS.Model.Comm;
using RCS.Model.Entity;
using RCS.Model.ManualModel;
using RCS.WinClient.Common;
using RCS.WinClient.Service;
using SqlSugar;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using static RCS.Model.Comm.EnumMsg;


namespace RCS.WinClient.Views.Pages
{
    /// <summary>
    /// WinTest.xaml 的交互逻辑
    /// </summary>
    public partial class WinTest : Window
    {
        public WinTest()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var manualTask = new string[] { EnumMsg.TaskType.普通行走.ToString(), EnumMsg.TaskType.倒车行走.ToString(),
                                            EnumMsg.TaskType.上升到顶.ToString(), EnumMsg.TaskType.下降到底.ToString(),
                                            EnumMsg.TaskType.充电.ToString(), EnumMsg.TaskType.取消充电.ToString(),
                                            EnumMsg.ActionType.旋转.ToString(),
                                            EnumMsg.ActionType.转盘旋转.ToString(),
                                            EnumMsg.ActionType.对中.ToString(),
            EnumMsg.TaskType.回家.ToString()};
            ComBox_ManualTask.ItemsSource = manualTask;

            string[] taskType = [TaskType.物料出库.ToString(), TaskType.物料入库.ToString(),TaskType.配送测试.ToString(), TaskType.展厅配送测试.ToString(),TaskType.展厅激光配送.ToString()];

            ComBox_TaskType.ItemsSource = taskType;

            Tbox_Agv.ItemsSource = App.AgvList.Select(x => x.AgvNo).ToList();

            //循环测试任务
            Tbox_Agv1.ItemsSource = App.AgvList.Select(x => x.AgvNo).ToList();
            ComBox_ManualTask1.ItemsSource = taskType;

            foreach (var item in taskType)
            {
                CheckBox checkBox = new CheckBox
                {
                    Content = item,
                    Margin = new Thickness(5)
                };
                Panel_TaskType.Children.Add(checkBox);
            }

            //ComBox_StartSt.IsDropDownOpen = true;
            //ComBox_StartSt.IsDropDownOpen = true;
        }

        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        //重写Closing方法
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            Hide();
            e.Cancel = true;
        }

        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DragMove();
        }

        /// <summary>
        /// 保存单步任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_OK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //int outNum = 0;
                var Tim = "0";
                var taskType = ComBox_ManualTask.SelectedValue as string;
                if (string.IsNullOrEmpty(taskType))
                {
                    ComnMethod.Message("请选择任务类型,不能手写!");
                    return;
                }
                var agvNo = Tbox_Agv.SelectedValue as string;
                if (string.IsNullOrEmpty(agvNo))
                {
                    ComnMethod.Message("请选择AGV,不能手写!");
                    return;
                }
                var agv = App.AgvList.FirstOrDefault(b => b.AgvNo == agvNo);
                if (agv == null)
                {
                    ComnMethod.Message("车号有误,请检查!");
                    return;
                }
                var startPoint = App.PointList.Find(a => a.Barcode == agv.Barcode);
                if (startPoint == null)
                {
                    ComnMethod.Message("AGV当前点不在地图中!");
                    return;
                }
                var endBarcode = ComBox_Position.SelectedValue as string;

                var taskGroup = EnumMsg.TaskGroup.RCS单步任务.ToString();

                string startBarcode = agv.Barcode;
                string startStationName = "";
                string endStationName = "";

                //如果是行走,就需要检查点位
                if (taskType == EnumMsg.TaskType.普通行走.ToString() || taskType == EnumMsg.TaskType.倒车行走.ToString())
                {
                    if (!App.PointList.Exists(x => x.Barcode == startBarcode))
                    {
                        ComnMethod.Message("起点点位未找到,请检查!");
                        return;
                    }
                    if (!App.PointList.Exists(x => x.Barcode == endBarcode))
                    {
                        ComnMethod.Message("终点点位未找到,请检查!");
                        return;
                    }
                }
                //叉车类型禁止往站台中发普通行走任务,会撞到货架
                if (taskType == TaskType.普通行走.ToString()
                   && agv.AgvType == AgvType.叉车
                   && (App.StationList.Any(x => x.Barcode == endBarcode)
                     || App.StationList.Any(x => x.PreBarcode == endBarcode && x.Name.StartsWith("A"))
                  ))
                {
                    ComnMethod.Message("叉车禁止往站台中发普通行走任务,会撞到货架!");
                    return;
                }

                //如果是取货、放货、充电,就需要检查站台
                if (taskType == EnumMsg.TaskType.充电.ToString())
                {
                    var endStation = App.StationList.FirstOrDefault(t => t.Name == endBarcode);
                    if (endStation == null)
                    {
                        ComnMethod.Message("目标站台未找到,请检查!");
                        return;
                    }
                    startStationName = endStation.Name;
                    endStationName = endStation.Name;
                    startBarcode = endStation.Barcode;
                    endBarcode = endStation.Barcode;
                    //手动充电任务.
                    if (taskType == EnumMsg.TaskType.充电.ToString())
                    {
                        agv.LockStation = endStation;
                        endStation.IsLocked = true;
                        var updateAgvResult = UpdateManage.UpdateAgv(agv);
                        var updateAtationResult = UpdateManage.UpdateStation(endStation);
                    }
                }

                //如果是 顶升、下降、取消充电,就不需要点位
                if (taskType == EnumMsg.TaskType.上升到顶.ToString()
                    || taskType == EnumMsg.TaskType.下降到底.ToString()
                    || taskType == EnumMsg.TaskType.取消充电.ToString()
                    || taskType == EnumMsg.TaskType.旋转.ToString()
                    || taskType == EnumMsg.TaskType.转盘旋转.ToString()
                       || taskType == EnumMsg.TaskType.对中.ToString()
                    )
                {
                    if (taskType == EnumMsg.TaskType.取消充电.ToString() && agv.AgvState != EnumMsg.AGVState.充电中)
                    {
                        ComnMethod.Message("不在充电中,不能取消充电!");
                        return;
                    }
                    startBarcode = agv.Barcode;
                    endBarcode = startBarcode;
                }
                else
                {
                    if (string.IsNullOrEmpty(endBarcode))
                    {
                        ComnMethod.Message("请选择目标,不能手写!");
                        return;
                    }
                }

                if (YesRadio.IsChecked == true)
                {
                    if (taskType == EnumMsg.TaskType.充电.ToString() || taskType == EnumMsg.TaskType.取消充电.ToString())
                    {
                        ComnMethod.Message("充电/取消充电不可以循环"); return;
                    }
                    App.StartCycle = 1;
                    App.ManualCycleList.Add(new ManualCycle()
                    {
                        AgvNo = Tbox_Agv.Text,
                        FromBarcode = startBarcode,
                        ToBarcode = endBarcode,
                        TaskType = ComBox_ManualTask.Text
                    });
                    ComnMethod.Message("循环任务建立成功!");
                }
                else
                {
                    short.TryParse(this.Tbx_HeightAngle.Text, out var heightOrAngle);
                    var result = TaskManage.TaskBuild(taskType, taskGroup, Tim, 1, Tbox_Agv.Text, startBarcode, endBarcode, "", startStationName, endStationName, heightOrAngle);
                    if (result.IsSuccess)
                    {
                        ComnMethod.Message("建立成功!");
                    }
                    else
                    {
                        ComnMethod.Message($"创建失败{result.Message}");
                    }
                }
            }
            catch (Exception ex)
            {
                ComnMethod.Message($"RCS产生单步任务失败!原因:{ex.Message}");
                App.ExFile.MessageError("WinTest", $"RCS产生单步任务异常,原因:{ex.Message},堆栈:{ex.StackTrace}");
            }
        }

        /// <summary>
        /// 关机
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Off_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //if (Combo_offType.Text == "")
                //{
                //    ComnMethod.Message("请选择关机小车!");
                //}
                //else
                //{
                //    App.offAgv = 1;
                //    App.offTime = DateTime.Now;
                //    App.OffAgvNos.Clear();
                //    if (Combo_offType.Text == "单独关机")
                //    {
                //        Base_Agv? getAgv = App.AgvList.FirstOrDefault(a => a.AgvNo == TBox_offAgvNo.Text);
                //        if (getAgv != null)
                //        {
                //            App.OffAgvNos.Add(TBox_offAgvNo.Text);
                //        }
                //    }
                //    else if (Combo_offType.Text == "全部关机")
                //    {
                //        foreach (Base_Agv agv in App.AgvList)
                //        {
                //            if (agv.IsEnable && agv.IsOnline)
                //            {
                //                App.OffAgvNos.Add(agv.AgvNo);
                //            }
                //            else
                //            {
                //                continue;
                //            }
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                App.ExFile.MessageError("WinTest", $"关机任务异常,原因:{ex.Message},堆栈:{ex.StackTrace}");
            }
        }

        /// <summary>
        /// 保存复合任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Task_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var taskID = ComBox_TaskType.SelectedValue as string;
                if (string.IsNullOrEmpty(taskID))
                {
                    ComnMethod.Message("请选择任务类型,不能手写!");
                    return;
                }
                var from = ComBox_StartStation.SelectedValue as string;
                if (string.IsNullOrEmpty(from))
                {
                    ComnMethod.Message("请选择 起点,不能手写!");
                    return;
                }
                var to = ComBox_EndStation.SelectedValue as string;
                if (string.IsNullOrEmpty(to))
                {
                    ComnMethod.Message("请选择 终点,不能手写!");
                    return;
                }

                Base_Point? fromPoint = null;
                Base_Point? toPoint = null;
                Base_Station? fromStation = null;
                Base_Station? toStation = null;

                fromStation = App.StationList.FirstOrDefault(a => a.Name == from);
                toStation = App.StationList.FirstOrDefault(a => a.Name == to);
                fromPoint = App.PointList.FirstOrDefault(x => x.Barcode == fromStation?.Barcode);
                toPoint = App.PointList.FirstOrDefault(x => x.Barcode == toStation?.Barcode);

                if (fromPoint == null)
                {
                    ComnMethod.Message("起始不存在!");
                    return;
                }
                if (!fromPoint.IsEnable)
                {
                    ComnMethod.Message("任务起点被禁用!");
                    return;
                }
                if (taskID != EnumMsg.TaskType.出库区任务.ToString())
                {
                    if (toPoint == null)
                    {
                        ComnMethod.Message("终点不存在!");
                        return;
                    }
                    if (!toPoint.IsEnable)
                    {
                        ComnMethod.Message("任务起点被禁用!");
                        return;
                    }
                }
                //var toLoction = App.LoctionList.Find(a => a.LoctionBarcode == toSt.Barcode);
                //if (toLoction != null)
                //{
                //    if(taskID==EnumMsg.TaskType.)
                //}

                //if (YesTaskRadio.IsChecked == true)
                //{
                //    App.StartCycle = 1;
                //    App.ManualCycleList.Add(new ManualCycle()
                //    {
                //        AgvNo = "",
                //        FromBarcode = fromStation.Barcode,
                //        ToBarcode = toStation.Barcode,
                //        TaskType = taskID
                //    });
                //    ComnMethod.Message("循环任务建立成功!");
                //    return;
                //}
                var taskGroup = EnumMsg.TaskGroup.RCS复合任务.ToString();
                var taskBuildRestult = TaskManage.TaskBuild(taskID, taskGroup, "1", 5, "", fromPoint.Barcode, toPoint?.Barcode, "", fromStation?.Name, toStation?.Name);
                if (!taskBuildRestult.IsSuccess)
                {
                    ComnMethod.Message($"生成任务失败!原因:{taskBuildRestult.Message}");
                    return;
                }
            }
            catch (Exception ex)
            {
                ComnMethod.Message($"RCS产生复合任务失败!原因:{ex.Message}");
                App.ExFile.MessageError("WinTest", $"RCS产生复合任务异常,原因:{ex.Message},堆栈:{ex.StackTrace}");
            }
            ComnMethod.Message("成功!!");
        }


        //private void Btn_StopManualTask_Click(object sender, RoutedEventArgs e)
        //{
        //    int index = -1;
        //    if (Tbox_Agv1.Text == "" && ComBox_ManualTask1.Text == "")
        //    {
        //        if (MessageBox.Show("请确认是否暂停全部循环任务", "确认", MessageBoxButton.YesNo) == MessageBoxResult.No) return;
        //        App.StartCycle = 0;
        //        App.ManualCycleList.Clear();
        //        //App.ManualAgvNoList.Clear();
        //        //App.EndBarcodeList.Clear();
        //        //App.StartBarcodeList.Clear();
        //        //App.ManualTaskList.Clear();
        //    }
        //    else
        //    {
        //        if (Tbox_Agv1.Text != "")
        //        {
        //            index = App.ManualCycleList.FindIndex(a => a.AgvNo == Tbox_Agv1.Text);
        //            if (index < 0) { ComnMethod.Message("AGV不在循环任务中"); return; }
        //        }
        //        else if (ComBox_ManualTask1.Text != "")
        //        {
        //            index = App.ManualCycleList.FindIndex(a => a.TaskType == ComBox_ManualTask1.Text);
        //            if (index < 0) { ComnMethod.Message("任务不在循环任务中"); return; }
        //        }
        //        App.ManualCycleList.RemoveAt(index);
        //        //App.EndBarcodeList.RemoveAt(index);
        //        //App.StartBarcodeList.RemoveAt(index);
        //        //App.ManualTaskList.RemoveAt(index);
        //        if (App.ManualCycleList.Count == 0)
        //        {
        //            App.StartCycle = 0;
        //        }
        //    }
        //    ComnMethod.Message("暂停成功!");
        //}

        /// <summary>
        /// 切换AGV
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Tbox_Agv_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var AgvNo = ((ComboBox)sender).SelectedItem as string;
            var taskType = ComBox_ManualTask.Text;
            if (taskType == EnumMsg.TaskType.充电.ToString())
            {
                var agvNo = Tbox_Agv.SelectedValue as string;
                if (string.IsNullOrEmpty(agvNo))
                {
                    ComnMethod.Message("请选择AGV,不能手写!");
                    return;
                }
                var agv = App.AgvList.FirstOrDefault(b => b.AgvNo == agvNo);
                if (agv == null)
                {
                    ComnMethod.Message("车号有误,请检查!");
                    return;
                }
                var chargeName = agv.ChargeName;
                var stationNames = App.StationList.Where(x => x.StationType == EnumMsg.StationType.充电桩).Select(x => x.Name);
                if (!chargeName.IsNullOrEmpty())
                    stationNames = stationNames.Where(t => t == chargeName);
                ComBox_Position.ItemsSource = stationNames;
            }
            else if (taskType == EnumMsg.TaskType.取消充电.ToString())
            {
                ComBox_Position.ItemsSource = null;
            }
        }

        /// <summary>
        /// 键盘输入筛选
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (sender is not ComboBox comboBox)
                return;
            var stationNameList = App.StationList.Where(x => x.StationType > EnumMsg.StationType.充电桩).Select(x => x.Name).ToList();
            var mylist = stationNameList.FindAll(x => x.Contains(comboBox.Text.Trim()));
            comboBox.ItemsSource = mylist;
            comboBox.IsDropDownOpen = true;
        }
        /// <summary>
        /// 切换单步任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComBox_ManualTask_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //ComBox_Position.Items.Clear();
            var taskType = ((ComboBox)sender).SelectedItem as string;
            if (taskType == EnumMsg.TaskType.充电.ToString())
            {
                var agv = App.AgvList.FirstOrDefault(b => b.AgvNo == Tbox_Agv.Text);
                var stations = App.StationList.FindAll(x => x.StationType == StationType.充电桩);
                if (agv != null)
                {
                    var chargeName = agv.ChargeName;
                    if (!string.IsNullOrEmpty(chargeName))
                    {
                        stations = stations.FindAll(x => x.Name == chargeName);
                    }
                }
                ComBox_Position.ItemsSource = stations.Select(x => x.Name);
            }
            else if (taskType.In(TaskType.普通行走.ToString(),
                TaskType.倒车行走.ToString(),
                TaskType.上升到顶.ToString(),
                TaskType.下降到底.ToString()))
            {
                var barcodes = App.PointList.Select(t => t.Barcode).OrderBy(int.Parse).ToList();
                ComBox_Position.ItemsSource = barcodes;
            }
            else if (taskType == EnumMsg.TaskType.回家.ToString())
            {
                var barcodes = App.PointList.Where(x => x.IsStop).Select(t => t.Barcode).OrderBy(int.Parse).ToList();
                ComBox_Position.ItemsSource = barcodes;
            }
            else
            {
                ComBox_Position.ItemsSource = null;
            }
        }

        /// <summary>
        /// 切换复合任务类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComBox_TaskType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var taskType = ((ComboBox)sender).SelectedItem as string;
            var stationNames = App.StationList.Where(x => x.StationType != EnumMsg.StationType.充电桩).Select(x => x.Name).ToList();
            ComBox_StartStation.ItemsSource = stationNames;
            ComBox_EndStation.ItemsSource = stationNames;

        }

        private void Btn_StartManualTask_Click(object sender, RoutedEventArgs e)
        {
            var agvNo = Tbox_Agv1.Text;
            var taskType = ComBox_ManualTask1.Text;
            if (string.IsNullOrEmpty(agvNo) || string.IsNullOrEmpty(taskType))
            {
                MessageBox.Show("请指定agv或者任务类型");
                return;
            }
            var agv = App.AgvList.Find(x => x.AgvNo == agvNo);
            if (agv != null)
            {
                var isExists = App.RecurrentTasks.Exists(x => x.agv.AgvNo == agvNo);
                if (isExists)
                {
                    MessageBox.Show($"{agvNo}已经存在循环任务");
                    return;
                }
                isExists = App.TaskList.Any(x => x.TaskAgvNo == agvNo);
                if (isExists)
                {
                    MessageBox.Show($"{agvNo}存在任务");
                    return;
                }
                App.RecurrentTasks.Add((agv, taskType));
                MessageBox.Show($"agv{agvNo}已经加入循环任务");
            }


            // RecurrentTasks
        }

        private void Btn_StopManualTask_Click(object sender, RoutedEventArgs e)
        {
            var agvNo = Tbox_Agv1.Text;
            var isExists = App.RecurrentTasks.Exists(x => x.agv.AgvNo == agvNo);
            if (isExists)
            {
                //var agv = App.RecurrentTasks.Find(x => x.agv.AgvNo == agvNo);
                //App.RecurrentTasks.Remove(agv);
                var count = App.RecurrentTasks.RemoveAll(x => x.agv.AgvNo == agvNo);
                MessageBox.Show($"已经成功移除{agvNo}的循环任务{count}");
            }
            else
                MessageBox.Show($"{agvNo}没有循环任务");
        }

        private void Btn_StartRadomTask_Click(object sender, RoutedEventArgs e)
        {

            if (int.TryParse(Tbox_RadomCount.Text, out var count))
            {
                var taskTypes = new List<string>();
                foreach (var child in Panel_TaskType.Children)
                {
                    if (child is CheckBox checkBox && (checkBox.IsChecked ?? false) && checkBox.Content != null)
                    {
                        taskTypes.Add((string)checkBox.Content);
                    }
                }

                App.RadomTaskConfig.Concurrency = count;
                App.RadomTaskConfig.IsStartRadom = true;
                App.RadomTaskConfig.TaskTypes = taskTypes;
                MessageBox.Show("操作成功");

            }
            else
            {
                MessageBox.Show("并发数量请填写数值类型");
            }
        }

        private void Btn_StopRadomTask_Click(object sender, RoutedEventArgs e)
        {

            App.RadomTaskConfig.IsStartRadom = false;
            MessageBox.Show("操作成功");

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Topmost = !this.Topmost;
            if (this.Topmost)
            {
              // this.Btn_Nail.for
            }
        }

        private void Btn_Nail_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.Topmost = !this.Topmost;
            if (this.Topmost)
            {
                this.Btn_Nail.Background = new SolidColorBrush(Color.FromRgb(230,230,230)); 
            }
            else
            {
                this.Btn_Nail.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)); 

            }
        }
    }
}