private void Instance_OnTerminated(InstanceIdentifier id, TaskbarApplicationInstanceButton instanceButton) { Dispatcher.InvokeAsync(() => { instances.Remove(instances.FirstOrDefault(i => i.Id == id)); InstanceStackPanel.Children.Remove(instanceButton); }); }
private void RemoveInstance(TaskbarApplicationInstanceButton button) { Dispatcher.InvokeAsync(() => { InstanceStackPanel.Children.Remove(button); if (InstanceStackPanel.Children.Count == 0) { single = default(IApplicationInstance); } }); }
public void RegisterInstance(IApplicationInstance instance) { Dispatcher.Invoke(() => { var instanceButton = new TaskbarApplicationInstanceButton(instance, info); instanceButton.Clicked += (id) => Clicked?.Invoke(id); instance.Terminated += (id) => Instance_OnTerminated(id, instanceButton); instances.Add(instance); InstanceStackPanel.Children.Add(instanceButton); }); }
private void Application_InstanceStarted(IApplicationInstance instance) { Dispatcher.Invoke(() => { var button = new TaskbarApplicationInstanceButton(instance, application.Info); instance.Terminated += (_) => RemoveInstance(button); InstanceStackPanel.Children.Add(button); if (single == default(IApplicationInstance)) { single = instance; } }); }