private void UpdateListbox()
        {
            int selectedIndex    = LST_Entries.SelectedIndex;
            int selectedCmbIndex = CMB_Mode.SelectedIndex;

            LST_Entries.BeginUpdate();
            LST_Entries.Items.Clear();
            foreach (var item in PluginSettings.Instance.ProtectedItems)
            {
                if (item.EntityId == -1)
                {
                    LST_Entries.Items.Add(".Default");
                }
                else
                {
                    MyEntity entity;
                    if (!MyEntities.TryGetEntityById(item.EntityId, out entity))
                    {
                        LST_Entries.Items.Add($"Invalid entityId: {item.EntityId}");
                        continue;
                    }
                    var grid = entity as MyCubeGrid;
                    if (grid == null)
                    {
                        LST_Entries.Items.Add($"Invalid entityId: {item.EntityId}");
                        continue;
                    }
                    LST_Entries.Items.Add($"{grid.DisplayName ?? ""}: {item.EntityId}");
                }
            }
            LST_Entries.SelectedIndex = selectedIndex;
            CMB_Mode.SelectedIndex    = selectedCmbIndex;
            LST_Entries.EndUpdate();
        }
 private void BTN_RemoveItem_Click(object sender, EventArgs e)
 {
     PluginSettings.Instance.ProtectedItems.RemoveAt(LST_Entries.SelectedIndex);
     if (PluginSettings.Instance.ProtectedItems.Count == 0)
     {
         LST_Entries.ClearSelected(  );
         LST_Entries.Items.Clear(  );
         splitContainer1.Panel2.Enabled = false;
     }
     else if (LST_Entries.SelectedIndex >= PluginSettings.Instance.ProtectedItems.Count)
     {
         LST_Entries.SelectedIndex--;
         UpdateListbox( );
     }
 }