Skip to content

Commit

Permalink
2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rjtwins committed Jul 25, 2021
2 parents 63a0e6e + 6f9d592 commit be98943
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 95 deletions.
78 changes: 41 additions & 37 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ private void Form1_Load(object sender, EventArgs e)
this.rotatingLabel1.NewText = "<- Low Priority/Loaded First --- High Priority/Loaded Last ->"; // whatever you want to display
this.rotatingLabel1.ForeColor = Color.Black; // color to display
this.rotatingLabel1.RotateAngle = -90; // angle to rotate

logic.CheckRequires(ListViewData);
logic.GetOverridingData(ListViewData);
}

//handling key presses for hotkeys.
Expand Down Expand Up @@ -492,7 +495,6 @@ private void LoadAndFill(bool FromClipboard)
ListViewData.Add(item1);
}

logic.GetOverridingData(ListViewData);
UpdateListView();
logic.SaveProgramData();
}
Expand All @@ -505,7 +507,6 @@ private void LoadAndFill(bool FromClipboard)
MessageBox.Show(message, caption, buttons);
}
this.LoadingAndFilling = false;
logic.CheckRequires(ListViewData);
}

//Fill list view from internal list of data.
Expand Down Expand Up @@ -857,21 +858,18 @@ private void toolStripButton1_Click(object sender, EventArgs e)
//Crude filter because to lazy to add a proper list as backup for the items.
private void filterBox_TextChanged(object sender, EventArgs e)
{
//Console.WriteLine("There are " + this.backupListView.Count() + " items in the backup");

string filtertext = MainForm.filterBox.Text.ToLower();
if (
filtertext == ""
|| string.IsNullOrWhiteSpace(MainForm.filterBox.Text)
|| string.IsNullOrEmpty(filtertext)
)
{
Console.WriteLine("No filter text");
//Console.WriteLine("No filter text");
if (this.filtered) //we are returning from filtering
{
foreach (ListViewItem x in this.ListViewData)
{
x.SubItems[0].BackColor = Color.White;
x.SubItems[1].BackColor = Color.White;
x.SubItems[2].BackColor = Color.White;
x.SubItems[3].BackColor = Color.White;
Expand All @@ -881,6 +879,7 @@ private void filterBox_TextChanged(object sender, EventArgs e)
}
else //We are not returning from a filter
{
//This should never happen. We can't return from a filter we never entered.
// do nothing
}
MainForm.button1.Enabled = true;
Expand All @@ -889,54 +888,59 @@ private void filterBox_TextChanged(object sender, EventArgs e)
}
else
{
Console.WriteLine("Filter Text: " + filtertext);
this.listView1.Items.Clear();

foreach (ListViewItem x in this.ListViewData)
{
x.SubItems[0].BackColor = Color.White;
x.SubItems[1].BackColor = Color.White;
x.SubItems[2].BackColor = Color.White;
x.SubItems[3].BackColor = Color.White;
x.SubItems[4].BackColor = Color.White;
}

//Check if the items modname, foltername or author stars with or contains the filter text
foreach (ListViewItem item in this.ListViewData)
this.filtered = true;
//Console.WriteLine("Filter Text: " + filtertext);
if (MainForm.checkBox1.Checked)
{
if (
item.SubItems[1].Text.ToLower().StartsWith(filtertext) ||
item.SubItems[2].Text.ToLower().StartsWith(filtertext) ||
item.SubItems[3].Text.ToLower().StartsWith(filtertext) ||
item.SubItems[1].Text.ToLower().Contains(filtertext) ||
item.SubItems[2].Text.ToLower().Contains(filtertext) ||
item.SubItems[3].Text.ToLower().Contains(filtertext)
)
foreach (ListViewItem item in this.ListViewData)
{
if (!MainForm.checkBox1.Checked)
if(MatchItemToText(filtertext, item))
{
MainForm.listView1.Items.Add(item);
}
else
{
item.SubItems[0].BackColor = Color.Yellow;
item.SubItems[1].BackColor = Color.Yellow;
item.SubItems[2].BackColor = Color.Yellow;
item.SubItems[3].BackColor = Color.Yellow;
item.SubItems[4].BackColor = Color.Yellow;
}
}
}
if (MainForm.checkBox1.Checked)
else
{
UpdateListView();
this.listView1.Items.Clear();
foreach (ListViewItem item in this.ListViewData)
{
if (MatchItemToText(filtertext, item))
{
item.SubItems[1].BackColor = Color.White;
item.SubItems[2].BackColor = Color.White;
item.SubItems[3].BackColor = Color.White;
item.SubItems[4].BackColor = Color.White;
MainForm.listView1.Items.Add(item);
}
}
}
MainForm.button1.Enabled = false;
MainForm.button2.Enabled = false;
this.filtered = true;
}
}

//Check all items in list view data and see if their content can be matched to a string.
private bool MatchItemToText(string filtertext, ListViewItem item)
{
if
(
item.SubItems[1].Text.ToLower().StartsWith(filtertext) ||
item.SubItems[2].Text.ToLower().StartsWith(filtertext) ||
item.SubItems[3].Text.ToLower().StartsWith(filtertext) ||
item.SubItems[1].Text.ToLower().Contains(filtertext) ||
item.SubItems[2].Text.ToLower().Contains(filtertext) ||
item.SubItems[3].Text.ToLower().Contains(filtertext)
)
{
return true;
}
return false;
}

//Filter or Highlight checkbox on tick action
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Expand Down
Loading

0 comments on commit be98943

Please sign in to comment.