Ejemplo n.º 1
0
 void service_GetAlarmReceiversCompleted(object sender, GetAlarmReceiversCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         e.Error.ShowError();
         return;
     }
     if (e.Result != null)
     {
         ReceiversTitle.Text = Group.Tag.ToString();
         ReceiversGrid.ItemsSource = e.Result.ToList();
         ReceiversGrid.Tag = e.Result;
         ReceiversGrid.Visibility = Visibility.Visible;
     }
     if (membercheck == true)
     {
         Receivers r = new Receivers() { UserName = new List<string>() };
         r.GropuName = Group.Tag.ToString();
         foreach (var a in e.Result.ToList())
         {
             r.UserName.Add(a.UserName);
         }
         var data = receiver.FirstOrDefault(s => s.GropuName == Group.Tag.ToString());
         if (data != null)
         {
             receiver.Remove(data);
         }
         else
         {
             receiver.Add(r);
         }
     }
     if (membercheck == false)
     {
         var data = receiver.FirstOrDefault(s => s.GropuName == Group.Tag.ToString());
         if (data != null)
         {
             receiver.Remove(data);
         }
     }
 }
Ejemplo n.º 2
0
 private void CheckBox_Click(object sender, RoutedEventArgs e)
 {
     Receivers r = new Receivers() { UserName = new List<string>() };
     var count = 0;
     var counttrue = 0;
     foreach (object ovj in ReceiversGrid.ItemsSource)
     {
         CheckBox cb = ReceiversGrid.Columns[4].GetCellContent(ovj).FindName("ck") as CheckBox;
         count++;
         if (cb.IsChecked.Value)
         {
             counttrue++;
             r.GropuName = Group.Tag.ToString();
             r.UserName.Add(cb.Tag.ToString());
         }
     }
     var data = receiver.FirstOrDefault(s => s.GropuName == Group.Tag.ToString());
     if (data != null)
     {
         receiver.Remove(data);
     }
     if (counttrue != 0)
     {
         receiver.Add(r);
     }
     Group.Children.OfType<CheckBox>().ToList().ForEach(member =>
         {
             if (member.Content.ToString() == Group.Tag.ToString())
             {
                 if (counttrue == count)
                 {
                     member.IsChecked = true;
                 }
                 else if (counttrue == 0)
                 {
                     member.IsChecked = false;
                 }
                 else
                 {
                     member.IsChecked = null;
                 }
             }
         });
 }