TaskBar Code
This blog entry is here for PDC2009 videos I am producing. When these videos are completed, they will be referenced here.
Code Snippet
- private void ShowOrHideOverlayIcon()
- {
- //TODO: Task 1--Using Taskbar Overlay Icons, steps 1-4
- if (ShowOverlay.IsChecked.Value)
- {
- Icon icon = iconsList.SelectedItem as Icon;
- if (icon != null)
- TaskbarManager.Instance.SetOverlayIcon(icon, "icon" + iconsList.SelectedIndex.ToString());
- }
- else
- {
- TaskbarManager.Instance.SetOverlayIcon(null, null);
- }
- }
UpdateProgress
Code Snippet
- private void UpdateProgress()
- {
- //TODO: Task 2--Using Taskbar Progress Bars, steps 1-5
- //if the checkbox is true
- // set the progress bar value
- //endif
- if (ShowProgressBar.IsChecked.Value)
- {
- // Set the max value for progress bar
- TaskbarManager.Instance.SetProgressValue((int)progressSlider.Value, 100);
- // This will cause a progress bar to appear in the application’s taskbar button,
- // providing an immediate progress indicator
- TaskbarManager.Instance.SetProgressState((TaskbarProgressBarState)ProgressStateSelection.SelectedItem);
- }
- else
- {
- TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress);
- }
- }
ProgressStateSelection_SelectionChanged
Code Snippet
- private void ProgressStateSelection_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- // TODO: For Check Box
- if ((TaskbarProgressBarState)ProgressStateSelection.SelectedItem == TaskbarProgressBarState.NoProgress)
- {
- ShowProgressBar.IsChecked = false;
- }
- else
- {
- ShowProgressBar.IsChecked = true;
- }
- UpdateProgress();
- }
ShowProgressBar_Click
Code Snippet
- private void ShowProgressBar_Click(object sender, RoutedEventArgs e)
- {
- //Logic:
- // If progress bar changes value, update the taskbar icon
- if (ShowProgressBar.IsChecked.Value)
- {
- ProgressStateSelection.SelectedItem = TaskbarProgressBarState.Normal;
- }
- else
- {
- ProgressStateSelection.SelectedItem = TaskbarProgressBarState.NoProgress;
- }
- UpdateProgress();
- }