private void PaintWoWs(object dummy) { if (this.Visibility.Equals(Visibility.Hidden)) { if (!this.IsVisible) { this.Dispatcher.Invoke(new Action(this.Show)); } else { return; } } if (v_series) { this.Dispatcher.Invoke(new Action(() => { var wowids = from p in Process.GetProcessesByName("WoW") select p.Id; if (wowids == null) { return; } if (wowids.SequenceEqual(WoWs)) { return; } else { WoWs = wowids; } ProcMap.Clear(); IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; foreach (var pid in wowids) { var MWH = Process.GetProcessById(pid).MainWindowHandle; ProcMap.Add(new WoWAttachVisual(MWH, pid)); } Sidebar.UpdateLayout(); })); } else { this.Dispatcher.Invoke(new Action(() => { Sidebar.Items.Clear(); Sidebar.ItemTemplate = default(DataTemplate); foreach (var wow in Process.GetProcessesByName("WoW")) { var lab = new TextBlock(); lab.Text = string.Format("{0} #{1}", wow.MainWindowTitle, wow.Id); lab.Margin = new Thickness(4); lab.Cursor = Cursors.Hand; lab.Tag = wow.Id; lab.MouseDown += new MouseButtonEventHandler(lab_MouseDown); Sidebar.Items.Add(lab); } Sidebar.UpdateLayout(); })); } }