private void EventsGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            EventRow ev   = e.Row.DataContext as EventRow;
            int      diff = (int)DateTime.Parse(ev.Deadline).Subtract(DateTime.Now).TotalDays;

            if (diff < 2)
            {
                e.Row.Background = new SolidColorBrush(Colors.Red);
            }
            else if (diff < 4)
            {
                e.Row.Background = new SolidColorBrush(Colors.Yellow);
            }
        }
        private void UpdateEventsGrid(int projectID)
        {
            Configuration config  = (App.Current as App).config;
            TcpClient     eClient = new TcpClient();

            try
            {
                eClient = new TcpClient(config.IP.ToString(), config.Port);
                using (NetworkStream writerStream = eClient.GetStream())
                {
                    MSG message = new MSG();
                    message.stat = STATUS.GET_EVENTS_BY_PROJECT;
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(writerStream, message);
                    formatter.Serialize(writerStream, projectID);
                    bool fl = (bool)formatter.Deserialize(writerStream);
                    if (fl)
                    {
                        EventCollection = (List <Event>)formatter.Deserialize(writerStream);
                        EventRow rw;
                        foreach (Event ev in EventCollection)
                        {
                            rw = new EventRow(ev.SerialNumber.ToString(), ev.Title,
                                              ev.DeadLine == new DateTime() ? "Не встановлено" : ev.DeadLine.ToShortDateString(),
                                              ev.AcceptDate == new DateTime() ? "Не здано" : ev.AcceptDate.ToShortDateString(),
                                              ev.RealMark.ToString(), ((1 - ev.Penalty) * 100).ToString() + "%");
                            EventsGrid.Items.Add(rw);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                eClient.Close();
            }
        }
 private void UpdateEventsGrid(int projectID)
 {
     Configuration config = (App.Current as App).config;
     TcpClient eClient = new TcpClient();
     try
     {
         eClient = new TcpClient(config.IP.ToString(), config.Port);
         using (NetworkStream writerStream = eClient.GetStream())
         {
             MSG message = new MSG();
             message.stat = STATUS.GET_EVENTS_BY_PROJECT;
             BinaryFormatter formatter = new BinaryFormatter();
             formatter.Serialize(writerStream, message);
             formatter.Serialize(writerStream, projectID);
             bool fl = (bool)formatter.Deserialize(writerStream);
             if (fl)
             {
                 EventCollection = (List<Event>) formatter.Deserialize(writerStream);
                 EventRow rw;
                 foreach (Event ev in EventCollection)
                 {
                     rw = new EventRow(ev.SerialNumber.ToString(), ev.Title,
                         ev.DeadLine == new DateTime() ? "Не встановлено" : ev.DeadLine.ToShortDateString(),
                         ev.AcceptDate == new DateTime() ? "Не здано" : ev.AcceptDate.ToShortDateString(),
                         ev.RealMark.ToString(), ((1 - ev.Penalty) * 100).ToString() + "%");
                     EventsGrid.Items.Add(rw);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         eClient.Close();
     }
 }