TaskBar Code

 

This blog entry is here for PDC2009 videos I am producing. When these videos are completed, they will be referenced here.

 

 

image

Code Snippet

  1. private void ShowOrHideOverlayIcon()
  2. {
  3.     //TODO: Task 1--Using Taskbar Overlay Icons, steps 1-4
  4.     if (ShowOverlay.IsChecked.Value)
  5.     {
  6.         Icon icon = iconsList.SelectedItem as Icon;
  7.         if (icon != null)
  8.             TaskbarManager.Instance.SetOverlayIcon(icon, "icon" + iconsList.SelectedIndex.ToString());
  9.     }
  10.     else
  11.     {
  12.         TaskbarManager.Instance.SetOverlayIcon(null, null);
  13.     }
  14. }

UpdateProgress

Code Snippet

  1. private void UpdateProgress()
  2. {
  3.     //TODO: Task 2--Using Taskbar Progress Bars, steps 1-5
  4.  
  5.     //if the checkbox is true
  6.     // set the progress bar value
  7.     //endif
  8.  
  9.     if (ShowProgressBar.IsChecked.Value)
  10.     {
  11.         // Set the max value for progress bar
  12.         TaskbarManager.Instance.SetProgressValue((int)progressSlider.Value, 100);
  13.         // This will cause a progress bar to appear in the application’s taskbar button,
  14.         // providing an immediate progress indicator
  15.         TaskbarManager.Instance.SetProgressState((TaskbarProgressBarState)ProgressStateSelection.SelectedItem);
  16.     }
  17.     else
  18.     {
  19.         TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress);
  20.     }
  21. }

ProgressStateSelection_SelectionChanged

Code Snippet

  1. private void ProgressStateSelection_SelectionChanged(object sender, SelectionChangedEventArgs e)
  2. {
  3.     // TODO: For Check Box
  4.     if ((TaskbarProgressBarState)ProgressStateSelection.SelectedItem == TaskbarProgressBarState.NoProgress)
  5.     {
  6.         ShowProgressBar.IsChecked = false;
  7.     }
  8.     else
  9.     {
  10.         ShowProgressBar.IsChecked = true;
  11.     }
  12.     UpdateProgress();
  13. }

ShowProgressBar_Click

Code Snippet

  1. private void ShowProgressBar_Click(object sender, RoutedEventArgs e)
  2. {
  3.  
  4.     //Logic:
  5.     // If progress bar changes value, update the taskbar icon
  6.     if (ShowProgressBar.IsChecked.Value)
  7.     {
  8.         ProgressStateSelection.SelectedItem = TaskbarProgressBarState.Normal;
  9.     }
  10.     else
  11.     {
  12.         ProgressStateSelection.SelectedItem = TaskbarProgressBarState.NoProgress;
  13.     }
  14.     UpdateProgress();
  15. }