Skip to content

Commit

Permalink
Add Rescan items to notify context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaier committed Oct 16, 2014
1 parent 74ac654 commit 90067a8
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 9 deletions.
37 changes: 28 additions & 9 deletions SimpleDLNA/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions SimpleDLNA/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,5 +576,60 @@ private void listDescriptions_DoubleClick(object sender, EventArgs e)
ButtonNewServer_Click(sender, e);
}
}

private void rescanAllContextMenuItem_Click(object sender, EventArgs e)
{
foreach (ServerListViewItem l in listDescriptions.Items) {
try {
l.Rescan();
}
catch (Exception) {
// no op
}
}
}

private void notifyContext_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
var items = new List<ToolStripItem>();
foreach (ToolStripItem i in notifyContext.Items) {
if (i.Tag != null) {
items.Add(i);
}
}
foreach (var i in items) {
notifyContext.Items.Remove(i);
}
items.Clear();
if (listDescriptions.Items.Count == 0) {
ContextSeperatorPre.Visible = false;
return;
}
ContextSeperatorPre.Visible = true;
foreach (ServerListViewItem item in listDescriptions.Items) {
if (!item.Description.Active) {
continue;
}
var innerItem = item;
var sm = new ToolStripMenuItem(item.Text);
sm.Tag = innerItem;
var rescan = sm.DropDownItems.Add("Rescan");
rescan.Click += (s, a) =>
{
try {
innerItem.Rescan();
}
catch (Exception) {
// no op
}
};
items.Add(sm);
}
items.Reverse();
var idx = notifyContext.Items.IndexOf(ContextSeperatorPre) + 1;
foreach (var i in items) {
notifyContext.Items.Insert(idx, i);
}
}
}
}

0 comments on commit 90067a8

Please sign in to comment.