コード例 #1
0
 void WindowManager_WindowRemoved(object sender, WindowEventArgs e)
 {
     Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
     {
         var foundItem = VMLocator.Main.Icons.FirstOrDefault(i => i.Windows.Any(w => w.Hwnd == e.Window.Hwnd));
         if (foundItem != null)
         {
             foundItem.Windows.Remove(e.Window);
             if (!foundItem.Windows.Any() && !foundItem.Pinned)
                 VMLocator.Main.Icons.Remove(foundItem);
         }
     }));
 }
コード例 #2
0
 void WindowManager_WindowAdded(object sender, WindowEventArgs e)
 {
     Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
     {
         var foundItems = VMLocator.Main.Icons.Where(i => PathTools.SamePath(i.Path, e.Window.FileName));
         IconViewModel windowIcon = null;
         if (foundItems.Any())
             windowIcon = foundItems.First();
         if (!foundItems.Any() || (windowIcon != null && windowIcon.Windows.Count > 0))
         {
             windowIcon = new IconViewModel()
             {
                 Name = Path.GetFileName(e.Window.FileName),
                 Path = e.Window.FileName,
                 Pinned = false
             };
             VMLocator.Main.Icons.Add(windowIcon);
         }
         windowIcon.Windows.Add(e.Window);
     }));
 }