• 《SystemTray》——— SystemTray的简单使用


    SystemTray控件也就是显示电池信号量的区域空间(如图)

    它可以做進度提示、广告等。

    1 SystemTray.BackgroundColor="<背景顏色>"
    2 SystemTray.ForegroundColor="<前景顏色>"
    3 SystemTray.Opacity="<透明度>"
    4 SystemTray.IsVisible="<啟動時是否顯示>">
    5 SystemTray.ProgressIndicatorProperty="<设置进度指示器(ProgressIndicator)>"

    下面是一个简单的使用例子

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Net;
     5 using System.Windows;
     6 using System.Windows.Controls;
     7 using System.Windows.Documents;
     8 using System.Windows.Input;
     9 using System.Windows.Media;
    10 using System.Windows.Media.Animation;
    11 using System.Windows.Shapes;
    12 using Microsoft.Phone.Controls;
    13 using Microsoft.Phone.Shell;
    14 using System.Windows.Threading;
    15 namespace TestSystemTray
    16 {
    17     public partial class MainPage : PhoneApplicationPage
    18     {
    19         // 建構函式
    20         public MainPage()
    21         {
    22             InitializeComponent();
    23         }
    24         private void button1_Click(object sender, RoutedEventArgs e)
    25         {
    26             ProgressIndicator _mangoIndicator = new ProgressIndicator();
    27             DispatcherTimer _timer = new DispatcherTimer();
    28             _timer.Interval = TimeSpan.FromSeconds(2);
    29             _timer.Tick += (obj, args) =>
    30             {
    31                 _mangoIndicator.IsVisible = false;
    32                 ClearValue(SystemTray.ProgressIndicatorProperty);
    33                 ClearValue(SystemTray.OpacityProperty);
    34                 ClearValue(SystemTray.BackgroundColorProperty);
    35                 ClearValue(SystemTray.ForegroundColorProperty);
    36                 (obj as DispatcherTimer).Stop();
    37                 obj = null;
    38             };
    39             _mangoIndicator.IsVisible = true;
    40             _mangoIndicator.Text = "不管你信不信,反正我信了";
    41             _mangoIndicator.IsIndeterminate = true;
    42             SetValue(SystemTray.ProgressIndicatorProperty, _mangoIndicator);
    43             SetValue(SystemTray.OpacityProperty, 0.9);
    44             SetValue(SystemTray.BackgroundColorProperty, Colors.Yellow);
    45             SetValue(SystemTray.ForegroundColorProperty, Colors.Blue);
    46             SystemTray.IsVisible = true;
    47             _timer.Start();
    48         }
    49     }
    50 }

    运行效果

    本文同步发表于:卤面网

    http://www.hugwp.com/article-404-1.html

    参考:http://blogs.msdn.com/b/ericsk/archive/2011/08/03/wp7-systemtray-progress-indication.aspx

  • 相关阅读:
    ios开发启动页面
    C++再学习之路(五)
    C++再学习之路(四)
    opencv再学习之路(九)---制作对焦图像
    opencv再学习之路(八)---轮廓检测
    C++再学习之路---例程(一) 文本查询
    opencv再学习之路(五)---灰度直方图显示
    opencv再学习之路(七)---图像单个元素的访问
    opencv再学习之路(六)---模板匹配
    C++再学习之路(三)
  • 原文地址:https://www.cnblogs.com/qq278360339/p/2555944.html
Copyright © 2020-2023  润新知