private void _dispatcherTimer_Tick(object sender, EventArgs e) { _dispatcherTimer.Stop(); var latestStatuses = _statusProvider.GetStatusList(_uriList); foreach (var newStatus in latestStatuses) { var oldStatus = _buildStatuses.Single(b => b.Key == newStatus.Key); if (newStatus.BuildId != oldStatus.BuildId) { var title = newStatus.BuildName; _taskbarIcon.ShowBalloonTip(title, MenuItemHelper.BuildBallonBody(newStatus), ResourceHelper.GetIcon(newStatus), true); foreach (var contextMenuItem in _contextMenu.Items) { var menuItem = contextMenuItem as MenuItem; var tag = menuItem?.Tag as Uri; if (tag == null || tag != oldStatus.Key) { continue; } MenuItemHelper.ConfigureMenuItem(menuItem, newStatus); } } oldStatus.Status = newStatus.Status; oldStatus.BuildId = newStatus.BuildId; oldStatus.RequestedBy = newStatus.RequestedBy; } _dispatcherTimer.Start(); }
private void BuildStandardMenuItems() { var exitItem = new MenuItem { Header = "Exit" }; exitItem.Click += ExitItem_Click; var launchItem = new MenuItem { Header = "Launch at Startup", IsCheckable = true, IsChecked = MenuItemHelper.GetStartupStatus() }; MenuItemHelper.SetStartup(launchItem.IsChecked); launchItem.Click += LaunchItem_Click; if (MenuItemHelper.CheckVersion()) { var newVersionItem = new MenuItem { Header = "Update available!", Icon = MenuItemHelper.GetImageFromResource( "pack://application:,,,/Resources/StatusWarning_256x.png") }; newVersionItem.Click += NewVersionItem_Click; _contextMenu.Items.Add(newVersionItem); } _contextMenu.Items.Add(launchItem); _contextMenu.Items.Add(exitItem); }
private void AddMenuItems(List <Uri> uriList) { _buildStatuses = _statusProvider.GetStatusList(uriList); foreach (var buildStatus in _buildStatuses) { var item = new MenuItem(); MenuItemHelper.ConfigureMenuItem(item, buildStatus); item.Click += ItemOnClick; _contextMenu.Items.Insert(0, item); } }
private void LaunchItem_Click(object sender, RoutedEventArgs e) { var menuItem = sender as MenuItem; MenuItemHelper.SetStartup(menuItem != null && menuItem.IsChecked); }
private void NewVersionItem_Click(object sender, RoutedEventArgs e) { MenuItemHelper.LaunchUpdateUrl(); }
private void ItemOnClick(object sender, RoutedEventArgs e) { MenuItemHelper.LaunchUrl(sender as MenuItem, _buildStatuses); }