wpf 进度条 下拉

<Window
x:Class="WpfApplication1.MainWindow"
       
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       
Title="MainWindow" Height="322" Width="525">
    <Grid
Height="218" Margin="0,3" HorizontalAlignment="Left"
Width="517">
       
<Grid.RowDefinitions>
           
<RowDefinition
Height="105*"/>
           
<RowDefinition
Height="113*"/>
       
</Grid.RowDefinitions>
       
<Rectangle Height="28" HorizontalAlignment="Left" Margin="64,24,0,0"
Name="rectangle1" Stroke="Black" VerticalAlignment="Top" Width="0"
/>
        <Label Content="进度:"
Height="28" HorizontalAlignment="Left" Margin="12,26,0,0" Name="label1"
VerticalAlignment="Top" />
       
<Button Content="开 始" Height="23" HorizontalAlignment="Left"
Margin="206,123,0,-33" Name="button1" VerticalAlignment="Top" Width="75"
Click="button1_Click" Grid.Row="1"
/>
        <Label Content="0%"
Margin="71,24,0,53" Name="label2" HorizontalAlignment="Left" Width="46"
/>
        <TextBox TextWrapping
="Wrap" HorizontalAlignment="Left" Margin="12,57,0,10" Name="textBox1"
Width="421"  Grid.RowSpan="2" TextChanged="textBox1_TextChanged"
/>
    </Grid>
</Window>

using System;
using System.Collections.Generic;
using
System.Linq;
using System.Text;
using System.Threading;
using
System.Threading.Tasks;
using System.Windows;
using
System.Windows.Controls;
using System.Windows.Data;
using
System.Windows.Documents;
using System.Windows.Input;
using
System.Windows.Media;
using System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using System.Windows.Shapes;
using
System.Windows.Threading;
using System.Data;
using
System.Data.SqlClient;

namespace
WpfApplication1
{
    ///
<summary>
    /// MainWindow.xaml
的交互逻辑
    /// </summary>
    //public
partial class MainWindow : Window
   
//{
    //    public
MainWindow()
    //    {
   
//       
InitializeComponent();
    //   
}

    //    private void
button1_Click(object sender, RoutedEventArgs e)
   
//    {

    //   
}

    //    private void
textBox1_TextChanged(object sender, TextChangedEventArgs
e)
    //    {

   
//    }
    //}
 
   
public partial class MainWindow : Window
   
{
      public  static double percent =
0;
      public static   int counts =
0;
      public static  int cc =
0;
      public static List<Menu> list =
null;
      public static List<Menu>
queryProgress()
     
{
          SqlConnection conn =
new SqlConnection();
         
conn.ConnectionString = "Data Source=.;Initial Catalog=CompanyGZ;Integrated
Security=True";
         
SqlCommand cmd = new
SqlCommand();
          string
sql = "SELECT * FROM
Menu;";
          cmd.Connection
= conn;
         
cmd.CommandText = sql;
         
conn.Open();
         
SqlDataAdapter adp = new
SqlDataAdapter(cmd);
         
DataSet ds = new
DataSet();
         
adp.Fill(ds);

         
DataTable dt =
ds.Tables[0];
          list =
new
List<Menu>();
         
list =
DataTable2List(dt);
         
counts =
int.Parse(ds.Tables[0].Rows.Count.ToString());
         
return list;

     
}

      private static List<Menu>
DataTable2List(DataTable dt)
     
{
          if (dt.Rows.Count
> 0)
         
{
             
List<Menu> list = new
List<Menu>();
             
Menu model =
null;
             
foreach (DataRow dr in
dt.Rows)
             
{
                 
model = new
Menu();
                 
LoadEntityData(model,
dr);
                 
list.Add(model);
             
}
             
return list;
         
}
          return
null;
      }
     
public static void LoadEntityData(Menu model, DataRow
dr)
     
{
          if
(dr.Table.Columns.Contains("mId") &&
!dr.IsNull("mId"))
         
{

             
model.Mid =
int.Parse(dr["mId"].ToString());
         
}
          model.MName =
dr["mName"].ToString();
         
model.MIsDel =
Convert.ToBoolean(dr["mIsDel"]);
         
model.MAddtime =
Convert.ToDateTime(dr["mAddtime"]);
     
}
        private delegate int
BrushProcessHandle();
        public
MainWindow()
       
{
           
InitializeComponent();
       
}

        Thickness
tmpT;

        private void
button1_Click(object sender, RoutedEventArgs
e)
       
{
           
queryProgress();
           
this.rectangle1.Width =
0;
            i =
1;
            if
(tmpT.Left == 0 && tmpT.Top == 0 && tmpT.Right == 0 &&
tmpT.Bottom ==
0)
           
{
               
tmpT =
this.label2.Margin;
           
}
           
else
           
{
               
this.label2.Margin =
tmpT;
           
}
           
this.textBox1.Text = "do
working...";
           
//
注释此句将百分比将会一直在进度条头部显示
           
this.label2.Margin = new Thickness(this.label2.Margin.Left - 52,
this.label2.Margin.Top, this.label2.Margin.Right,
this.label2.Margin.Bottom);
           
//
取消注释字体颜色为白色
           
//this.label2.Foreground =
Brushes.White;
           
//
取消注释字体为斜体
           
//this.label2.FontStyle =
FontStyles.Italic;
           
BrushProcessBar();
         
 
       
}

        private DispatcherTimer
dt;
        private int i =
1;
        private void
BrushProcessBar()
       
{
            dt = new
DispatcherTimer();
           
dt.Interval = new
TimeSpan(10000);
           
dt.Tick += new
EventHandler(dt_Tick);
           
dt.Start();
       
}

        protected void
dt_Tick(object sender, EventArgs
e)
       
{
            //
纯色进度条
           
//SolidColorBrush scb = new
SolidColorBrush();
           
//scb.Color = Color.FromRgb(63, 134,
231);

           
//
渐变进度条

           
LinearGradientBrush scb = new LinearGradientBrush(Color.FromRgb(63, 169, 233),
Color.FromRgb(16, 111, 197),
0);
           
this.rectangle1.Width =
i++;
           
this.label2.Margin = new Thickness(this.label2.Margin.Left + 1,
this.label2.Margin.Top, this.label2.Margin.Right,
this.label2.Margin.Bottom);
           
this.rectangle1.Fill =
scb;
            //if
(i == 50 || i == 120 || i ==
410)
           
//{
           
//   
Thread.Sleep(200);
           
//}
           
//this.label2.Content = Decimal.Round(((decimal)i) / 400 * 100, 2) + "%";//i ==
400

            if
(percent ==
100)
           
{
               
dt.Stop();
             
//  this.label2.Visibility
=Visibility.Hidden;
               
this.textBox1.Text +=
"\r\nCompleted";
           
}
           
else
           
{
             
 

               
if (cc <=
counts)
               
{
                  
cc=cc+1;
               
}
               
textBox1.Text = "do
working...";
               
for (int j = 0; j < 6;
j++)
               
{
                   
if (cc + j >=
counts)
                   
{
                    
 
                       
percent =
100;
                       
this.label2.Content = ("" + Convert.ToInt16(percent) +
"%");
                       
return
;
                   
// Decimal.Round(((cc)) / counts * 100, 2) + "%";//i ==
400
                   
}
                   
textBox1.Text += "\n"+list[cc+j].Mid + ":" + list[cc+j].MName + ":" +
list[cc+j].MIsDel +
list[cc+j].MAddtime+"\n";
                   
percent =Convert.ToDouble( cc )/
counts*100;
                   
this.label2.Content =(""+Convert.ToInt16( percent)+ "%");//i ==
400
                
 
               
}
          
//this.textBox1.Text+=
 
               
if (percent == 100)
return;
           
}
     
       
}

        private void
Window_Loaded(object sender, RoutedEventArgs
e)
       
{

       
}

        private void
textBox1_TextChanged(object sender, TextChangedEventArgs
e)
       
{

       
}

      
   
}
}

wpf 进度条 下拉,码迷,mamicode.com

时间: 2024-11-02 18:03:28

wpf 进度条 下拉的相关文章

很酷的导航条下拉效果

<style type="text/css"><!--.p9{ font-family: "宋体"; font-size: 9pt; }body { font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 0px; margin-right: 0px}UNKNOWN { TEXT-DECORATION: none}A:visited { TEXT-DECO

WPF 进度条ProgressBar

今天研究了一下wpf的进度条ProgressBar 1.传统ProgressBar WPF进度条ProgressBar 这个控件,如果直接写到循环里,会死掉,界面会卡死,不会有进度.需要把进度条放到单独的线程中. 传统的需要建立 Thread 或者使用 Timer,分别写在不同的方法中.但现在,使用 Dispatcher.Invoke 调用可以实现这个目的. for (int i = 0; i <= 10000; i++)            {                double v

WPF进度条系列②旋转小圆圈

 写在之前: 关于WPF的样式,我也是学习了很多朋友的文章才有了下面的东西,因为时间有些久远 & 备份的链接也都不在了. 所以,究竟是看过哪些文章,也是记不清楚了…… 请见谅. --------------------------------我是害羞的分割线----------------------------------- 旋转小圆圈进度条见效果: xaml: <UserControl x:Class="AppHost.ProbarRotate" xmlns=&quo

JQ-滚动条下拉无限的加载数据

一.原理 利用滚动的高度,如果滚动的高度到达一定范围,就加载数据 二.实现 利用$(document.body).outerWidth()获取的是屏幕的高度,这个是固定的,不变的 利用$(window).scrollTop()获取您滚动的高度 利用$(document).height()获取总的高度 注:$(widnow).height()这个是可视区的高度,这个跟$(document).height()很容易混淆 三.上代码 <section> <div id="tishi&

React实现顶部固定滑动式导航栏(导航条下拉一定像素时显示原导航栏样式)

摘要 基于react的框架开发一个顶部固定滑动式的酷炫导航栏,当导航栏置顶时,导航栏沉浸在背景图片里:当鼠标滑动滚轮时,导航栏固定滑动并展示下拉样式. HTML部分 相关技术栈:react.antd.react-router.详细的技术栈应用请参考官方文档的使用说明. * 展示主页App.jsx组件代码 import React from 'react'; import './App.css'; import { Link, Route } from 'react-router-dom'; im

WPF 进度条

前台新建一个控件ProgressBar控件,并命名为pbDown            WebRequest request = WebRequest.Create("http://files.cnblogs.com/fornet/404.rar");            WebResponse respone = request.GetResponse();            pbDown.Maximum = respone.ContentLength;           

Photoshop和WPF双剑配合,打造炫酷个性的进度条控件

现在如果想打造一款专业的App,UI的设计和操作的简便性相当重要.UI设计可以借助Photoshop或者AI等设计工具,之前了解到WPF设计工具Expression Blend可以直接导入PSD文件或者AI设计文件(当然不是全部特征支持),最近研究了一下,也废了一番周折,好在最后实现了预期的效果.下面将step by step用示例说明如何先用PS构建一个矢量图形模板,然后用Expression Blend导入PSD文件,并获取PATH的Data值,为打造一款炫酷的个性进度条控件构建美观UI.

支持下拉刷新和上划加载更多的自定义RecyclerView(仿XListView效果)

首先看效果 下拉刷新:        上划加载        在项目更新的过程中,遇到了一个将XListView换成recyclerView的需求,而且更换完之后大体效果不能变,但是对于下拉刷新这样的效果,谷歌给出的解决方案是把RecyclerView放在一个SwipeRefreshLayout中,但是这样其实是拉下一个小圆形控件实现的,和XListView的header效果不同.在网上找了很多的别人代码,都没有实现我想要的效果,于是自己动手写了一个. 具体实现的效果有以下几条 下拉刷新功能:

2019如何刷百度电脑下拉框?

如何刷百度下拉框? 巧推网业务主要是快速排名和下拉框排名,今天小编给大家说说百度下拉框排名是怎么刷,以及效果如何?下面先看看我们给自己刷的几个案例: 以上是2个百度电脑端下拉框案例,我们可以看到其构成是“主关键词”+后缀副词:比如“企业排名优化”是主词,“巧推网”就是后缀词,我们在刷词的时候,后缀一般都是我们的品牌词.这样用户点击这个下拉词的时候,就会匹配到我们官网信息,从而起到引流的作用. 不仅如此,即时用户没有点击进来,也起到了增加我们品牌词曝光率. 刷下拉词的大概原理就是系统模仿用户的搜索