예제 #1
0
 public void UpdateChecks(string c)
 {
     updating = true;
     try
     {
         tJunkLocationsString.Text = c;
         CustomJunkLocationsString = c;
         CustomJunkLocations.Clear();
         string[] v  = c.Split('-');
         int[]    vi = new int[ItemGroupCount];
         if (v.Length != vi.Length)
         {
             ExternalLabel = "Invalid junk locations string";
             return;
         }
         for (int i = 0; i < ItemGroupCount; i++)
         {
             if (v[ItemGroupCount - 1 - i] != "")
             {
                 vi[i] = Convert.ToInt32(v[ItemGroupCount - 1 - i], 16);
             }
         }
         for (int i = 0; i < 32 * ItemGroupCount; i++)
         {
             int j = i / 32;
             int k = i % 32;
             if (((vi[j] >> k) & 1) > 0)
             {
                 if (i >= ItemUtils.AllLocations().Count())
                 {
                     throw new IndexOutOfRangeException();
                 }
                 CustomJunkLocations.Add(_junkLocations[i]);
             }
         }
         foreach (ListViewItem l in lJunkLocations.Items)
         {
             if (CustomJunkLocations.Contains(_junkLocations[l.Index]))
             {
                 l.Checked = true;
             }
             else
             {
                 l.Checked = false;
             }
         }
         ExternalLabel = $"{CustomJunkLocations.Count}/{_junkLocations.Count} locations selected";
     }
     catch
     {
         CustomJunkLocations.Clear();
         ExternalLabel = "Invalid junk locations string";
     }
     finally
     {
         updating = false;
     }
 }
예제 #2
0
 private void PrintToListView()
 {
     foreach (var item in _junkLocations)
     {
         if (!item.Location().ToLower().Contains(tSearchString.Text.ToLower()))
         {
             continue;
         }
         lJunkLocations.Items.Add(new ListViewItem {
             Text = item.Location(), Tag = item, Checked = CustomJunkLocations.Contains(item)
         });
     }
 }
예제 #3
0
 private void lJunkLocations_ItemChecked(object sender, ItemCheckedEventArgs e)
 {
     if (updating)
     {
         return;
     }
     updating = true;
     if (e.Item.Checked)
     {
         CustomJunkLocations.Add(_junkLocations[e.Item.Index]);
     }
     else
     {
         CustomJunkLocations.Remove(_junkLocations[e.Item.Index]);
     }
     UpdateString(CustomJunkLocations);
     updating = false;
 }