- 浏览: 62481 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (93)
- java (3)
- ios (9)
- wp (15)
- android (0)
- js (1)
- 服务器 (0)
- db (0)
- linux (1)
- python (0)
- xcode (0)
- ide (2)
- maven (0)
- spring (0)
- sql (0)
- 第三方 (1)
- nexus (0)
- nginx (11)
- tomcat (0)
- jenkins (0)
- zookeeper (1)
- git (1)
- svn (0)
- uml (0)
- redis (4)
- activemq (1)
- flume (0)
- kafka (0)
- mysql (1)
- memcached (0)
- mybatis (0)
- mac (0)
- mongo (1)
- docker (6)
- cache (0)
- jvm (0)
- markdown (0)
- springboot (24)
- mycat (3)
- LTS (3)
- 运维 (0)
- opts (1)
- netty (1)
- tcc (0)
- ffmpeg (2)
- 直播 (6)
- cxf (0)
- nodejs (0)
- storm (0)
- elasticjob (0)
- php (0)
最新评论
MProgress.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
namespace MyControl.M
{
public partial class MProgress : UserControl
{
public Color ForeColor
{
get { return (Color)GetValue(MProgressForeColorProperty); }
set { SetValue(MProgressForeColorProperty, value); }
}
public Color BackColor
{
get { return (Color)GetValue(MProgressBackColorProperty); }
set { SetValue(MProgressBackColorProperty, value); }
}
public static readonly DependencyProperty MProgressForeColorProperty =
DependencyProperty.Register("ForeColor", typeof(Color), typeof(MProgress),
new PropertyMetadata(Colors.Black, OnColorChanged));
public static readonly DependencyProperty MProgressBackColorProperty =
DependencyProperty.Register("BackColor", typeof(Color), typeof(MProgress),
new PropertyMetadata(Colors.White, OnColorChanged));
private static void OnColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
MProgress progress = obj as MProgress;
if (e.Property == MProgressForeColorProperty)
{
progress.textBlock.Foreground = new SolidColorBrush((Color)e.NewValue);
}
if (e.Property == MProgressBackColorProperty)
{
progress.LayoutRoot.Background = new SolidColorBrush((Color)e.NewValue);
}
}
private DispatcherTimer timer = null;
public MProgress()
{
InitializeComponent();
timer = new DispatcherTimer();
}
public void setText(String text)
{
textBlock.Text = text;
}
public void startLoading()
{
//progressBar.Visibility = Visibility.Collapsed;
progressBar.Visibility = System.Windows.Visibility.Visible;
LayoutRoot.Visibility = System.Windows.Visibility.Visible;
}
public void stopLoading()
{
//progressBar.Visibility = Visibility.Collapsed;
progressBar.Visibility = System.Windows.Visibility.Visible;
LayoutRoot.Visibility = System.Windows.Visibility.Collapsed;
}
public void startLoadingWithText(String text)
{
textBlock.Text = text;
progressBar.Visibility = System.Windows.Visibility.Visible;
LayoutRoot.Visibility = System.Windows.Visibility.Visible;
}
public void stopLoadingWithText(String text)
{
timer.Stop();
textBlock.Text = text;
progressBar.Visibility = System.Windows.Visibility.Collapsed;
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += (s, ev) =>
{
LayoutRoot.Visibility = System.Windows.Visibility.Collapsed;
timer.Stop();
};
timer.Start();
}
}
}
========================================================================================
MProgress.xaml
<UserControl x:Class="MyControl.M.MProgress"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
x:Name="this">
<Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="#ee000000"
Visibility="Collapsed">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<ProgressBar
x:Name="progressBar"
HorizontalAlignment="Stretch"
Height="50"
VerticalAlignment="Center"
IsIndeterminate="true"
Visibility="Collapsed" />
<TextBlock x:Name="textBlock"
Foreground="White"
Text=""
Margin="5,0,0,5"
TextWrapping="Wrap"
FontSize="22"
Height="35"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</StackPanel>
</Grid>
</UserControl>
========================================================================================
使用方式:
<phone:PhoneApplicationPage
x:Class="MyControl.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sam="clr-namespace:MyControl.M"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True"
>
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="200"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<sam:MProgress HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="bar" Grid.RowSpan="2"></sam:MProgress>
<Button Grid.Row="0" Content="Button1" Height="72" x:Name="myButton11" Width="160" Click="click" Margin="10"/>
</Grid>
</phone:PhoneApplicationPage>
效果:
注意:
使用时 指定命名空间xmlns:sam="clr-namespace:MyControl.M"
使用时注意调用开头<sam: />
类一定要是public的 否则不能在配置文件中调用
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
namespace MyControl.M
{
public partial class MProgress : UserControl
{
public Color ForeColor
{
get { return (Color)GetValue(MProgressForeColorProperty); }
set { SetValue(MProgressForeColorProperty, value); }
}
public Color BackColor
{
get { return (Color)GetValue(MProgressBackColorProperty); }
set { SetValue(MProgressBackColorProperty, value); }
}
public static readonly DependencyProperty MProgressForeColorProperty =
DependencyProperty.Register("ForeColor", typeof(Color), typeof(MProgress),
new PropertyMetadata(Colors.Black, OnColorChanged));
public static readonly DependencyProperty MProgressBackColorProperty =
DependencyProperty.Register("BackColor", typeof(Color), typeof(MProgress),
new PropertyMetadata(Colors.White, OnColorChanged));
private static void OnColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
MProgress progress = obj as MProgress;
if (e.Property == MProgressForeColorProperty)
{
progress.textBlock.Foreground = new SolidColorBrush((Color)e.NewValue);
}
if (e.Property == MProgressBackColorProperty)
{
progress.LayoutRoot.Background = new SolidColorBrush((Color)e.NewValue);
}
}
private DispatcherTimer timer = null;
public MProgress()
{
InitializeComponent();
timer = new DispatcherTimer();
}
public void setText(String text)
{
textBlock.Text = text;
}
public void startLoading()
{
//progressBar.Visibility = Visibility.Collapsed;
progressBar.Visibility = System.Windows.Visibility.Visible;
LayoutRoot.Visibility = System.Windows.Visibility.Visible;
}
public void stopLoading()
{
//progressBar.Visibility = Visibility.Collapsed;
progressBar.Visibility = System.Windows.Visibility.Visible;
LayoutRoot.Visibility = System.Windows.Visibility.Collapsed;
}
public void startLoadingWithText(String text)
{
textBlock.Text = text;
progressBar.Visibility = System.Windows.Visibility.Visible;
LayoutRoot.Visibility = System.Windows.Visibility.Visible;
}
public void stopLoadingWithText(String text)
{
timer.Stop();
textBlock.Text = text;
progressBar.Visibility = System.Windows.Visibility.Collapsed;
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += (s, ev) =>
{
LayoutRoot.Visibility = System.Windows.Visibility.Collapsed;
timer.Stop();
};
timer.Start();
}
}
}
========================================================================================
MProgress.xaml
<UserControl x:Class="MyControl.M.MProgress"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
x:Name="this">
<Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="#ee000000"
Visibility="Collapsed">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<ProgressBar
x:Name="progressBar"
HorizontalAlignment="Stretch"
Height="50"
VerticalAlignment="Center"
IsIndeterminate="true"
Visibility="Collapsed" />
<TextBlock x:Name="textBlock"
Foreground="White"
Text=""
Margin="5,0,0,5"
TextWrapping="Wrap"
FontSize="22"
Height="35"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</StackPanel>
</Grid>
</UserControl>
========================================================================================
使用方式:
<phone:PhoneApplicationPage
x:Class="MyControl.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sam="clr-namespace:MyControl.M"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True"
>
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="200"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<sam:MProgress HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="bar" Grid.RowSpan="2"></sam:MProgress>
<Button Grid.Row="0" Content="Button1" Height="72" x:Name="myButton11" Width="160" Click="click" Margin="10"/>
</Grid>
</phone:PhoneApplicationPage>
效果:
注意:
使用时 指定命名空间xmlns:sam="clr-namespace:MyControl.M"
使用时注意调用开头<sam: />
类一定要是public的 否则不能在配置文件中调用
发表评论
-
wp win8开发:scrollview滑动动画效果
2017-01-10 17:07 482产品需求,暂别ios开发,着手win8开发。 说说这个scr ... -
wp wp8:自定义Button图片背景
2017-01-10 17:11 350自定义一个返回按钮,以下是我的操作。 内容部分也是在网上 ... -
wp wp8:指定通信资源(端口)已由另一个应用程序使用 错误
2017-01-10 17:06 440测试机器是820t时,一直正常运行,后来改用920t的时候安装 ... -
wp wp8:服务器推送
2017-01-11 13:32 441前提:必须使用真机,真机注册 服务器端使用的是winform ... -
wp wp8:lbs
2017-01-12 10:51 468上码:不解释 using System; using Sys ... -
wp wp8:计划通知
2017-01-10 17:06 425using System; using System.Coll ... -
wp wp8:后台任务
2017-01-10 17:10 412MScheduledTaskAgent项目下 Schedule ... -
wp wp8:页面转换 page transitions
2017-01-12 10:47 549首先导入Toolkit.dll文件 将App.xaml.cs ... -
wp wp8:公共样式定义
2017-02-07 10:12 492在Resources下创建一个名称为buttonStyle.x ... -
wp wp8:后台传输服务
2017-01-11 13:27 4821.TransferPreferences属性设置: 后台传 ... -
wp wp8:自定义dll库创建
2017-01-11 13:28 506鉴于项目测试: 创建一个wp8项目 在解决方案下 右键 操 ... -
wp wp8:sqlite安装
2017-01-12 10:47 483打开vs 检测一下时候安装了sqlite for window ... -
wp wp8:手势GuestureService/GuestureListener
2017-01-12 10:51 5761.利用Silverlight Tookit中提供的手势服务监 ... -
wp wp8&win8:Stretch的Uniform和UniformToFill
2017-01-12 10:51 601Uniform,控件的高度和宽度会增加直到达到了容器的大小,也 ...
相关推荐
在本教程中,我们将探讨如何在WP8.1中实现一个仿Android风格的自定义Progressbar。这个Progressbar不仅在外观上接近Android,还可能包含一些Android特有的交互特性。 首先,让我们理解什么是Progressbar。...
在Windows Phone 7 (WP7)开发中,创建一个等待进度条可以提供用户友好的界面...通过合理地使用ProgressIndicator控件,结合异步编程和自定义样式,开发者能够为用户提供一个明确的反馈机制,增强应用的交互性和专业性。
1. 创建进度条控件:在XAML布局文件中,我们可以添加一个ProgressBar控件,用于显示加载进度。可以通过设置其Visibility属性来控制是否显示,通过Value属性设置当前进度。 2. 启动后台任务:在后台线程执行耗时操作...
1. **ProgressBar控件**:这是Windows Phone 7中用于表示进度的内置控件。通过调整其`Value`属性,可以改变进度条的填充程度。同时,可以通过设置`IsIndeterminate`属性来决定进度条是否显示不确定的动画(如圆形...
如何做上图的效果,实际需要的是两个控件,一个是显示文字 的 TextBlock 一个是进度条。 那么如何让 文字和左边的距离变化?使用 TranslateTransform 看起来 Marquez 的界面就是: <ProgressBar x:Name=Mcdon ...
- **ProgressBar**:用于显示任务进度。 - **PageTitle**:用于设置页面标题。 - **PanoramaApplication**:用于创建全景应用,展示多个视图。 - **PivotControl**:用于创建可以旋转的界面。 #### Windows Phone ...