快捷搜索:

效果有点类似VS2012安装界面

作者: 电脑单机下载  发布:2019-11-27

  为了分界面友好,平常的操作时间较长时,都急需追加进程条提醒。由于WPF自带的进程条其实有一些美观,并且没啥视觉效果。后来,装VS二〇一一时,开采安装进程中进程条效果不错,于是上网查了素材。学习了ModernUI(开源的卡塔 尔(英语:State of Qatar),地址:。

  后来,做了尝试写了个德姆o,效果不错。别的,特地摄像了tif文件,方便大家看见功能。废话十分的少说,先出示效果:

电脑单机下载,一、效果呈现

  A、VS二〇一一安装分界面图;

         电脑单机下载 1

  B、个人品味德姆o效果图: 

       电脑单机下载 2

二、完成认证

  1、下载MUI相关代码也许dll文件;

  2、工程中引进该dll,并引进其能源文件;

<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.xaml" />
                <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.Light.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

  3、在必要展现进程条的页面,参加控件(其实照旧WPF控件,只是MUI扩大了其样式而已卡塔尔国;

<Label Margin="280,169,0,0" Style="{StaticResource BackGroundContentText}" x:Name="lblMainState" HorizontalAlignment="Left" VerticalAlignment="Top">正在启动:</Label>
        <ProgressBar Margin="280,200,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="500" Minimum="0" x:Name="ProgressControlRealValue" Maximum="1"  Value="0.1" Height="16" IsIndeterminate="False"/>
        <Label Margin="280,212,0,0" Style="{StaticResource BackGroundContentText}" x:Name="lblProcess" HorizontalAlignment="Left" VerticalAlignment="Top">正在加载地图数据...</Label>
        <ProgressBar Margin="280,250,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"  Minimum="0" x:Name="ProgressControl"  Width="500" Maximum="2" Height="16" IsIndeterminate="True" />

  4、后台完成,由于要依附事态更新速度文字及进程条的值。所以,这里运用了异步BackgroundWorker(具体能够网络查占星关材质卡塔尔国;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Monitor.Class
{
    /// <summary>
    /// 异步操作
    /// </summary>
    public class CWorker
    {
        /// <summary>
        /// 对象
        /// </summary>
        private BackgroundWorker backgroundWorker;

        /// <summary>
        /// 后台执行的操作
        /// </summary>
        public Action BackgroundWork { get; set; }

        /// <summary>
        /// 后台任务执行完毕后事件
        /// </summary>
        public event EventHandler<BackgroundWorkerEventArgs> BackgroundWorkerCompleted;

        private BackgroundWorkerEventArgs _eventArgs;//异常参数

        /// <summary>
        /// 构造
        /// </summary>
        public CWorker()
        {
            _eventArgs = new BackgroundWorkerEventArgs();
            backgroundWorker = new BackgroundWorker();
            backgroundWorker.WorkerReportsProgress = true;
            backgroundWorker.WorkerSupportsCancellation = true;
            backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
        }

        /// <summary>
        /// 开始工作
        /// </summary>
        public void BegionWork()
        {
            if (backgroundWorker.IsBusy)
                return;
            backgroundWorker.RunWorkerAsync();
        }

        /// <summary>
        /// 工作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            if (BackgroundWork != null)
            {
                try
                {
                    BackgroundWork();
                }
                catch (Exception ex)
                {
                    _eventArgs.BackGroundException = ex;
                }
            }
        }

        /// <summary>
        /// 完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (this.BackgroundWorkerCompleted != null)
            {
                this.BackgroundWorkerCompleted(null, _eventArgs);
            }
        }
    }

    /// <summary>
    /// 事件
    /// </summary>
    public class BackgroundWorkerEventArgs : EventArgs
    {
        /// <summary>
        /// 后台程序运行时抛出的异常
        /// </summary>
        public Exception BackGroundException { get; set; }
    }
}

namespace Monitor
{
    /// <summary>
    /// Splash.xaml 的交互逻辑
    /// </summary>
    public partial class Splash : Window
    {
        MainWindow m_MainWindow = null;//主窗口
        CWorker m_Work = null;//任务

        public Splash()
        {
            InitializeComponent();
            m_MainWindow = new MainWindow();//创建主窗口对象
            m_Work = new CWorker();
            m_Work.BackgroundWork = this.ProcessDo;
            m_Work.BackgroundWorkerCompleted += new EventHandler<BackgroundWorkerEventArgs>(m_Work_BackgroundWorkerCompleted);
        }

        /// <summary>
        /// 进度提示
        /// </summary>
        public void ProcessDo()
        {
            m_MainWindow.InitData(this);
        }

        /// <summary>
        /// 移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }

        /// <summary>
        /// 窗口加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            m_Work.BegionWork();
        }

        /// <summary>
        /// 执行完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void m_Work_BackgroundWorkerCompleted(object sender, BackgroundWorkerEventArgs e)
        {
            m_MainWindow.Show();
            this.Close();
        }

        /// <summary>
        /// 赋值
        /// </summary>
        /// <param name="text"></param>
        private delegate void SetProcessLabelDelegate(string text, double processValue);
        public void SetProcessValue(string text, double processValue)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(DispatcherPriority.Send, new SetProcessLabelDelegate(SetProcessValue), text, processValue);
                return;
            }
            this.lblProcess.Content = text;
            this.ProgressControlRealValue.Value = processValue;
        }
    }
}

 

本文由云顶娱乐棋牌游戏发布于电脑单机下载,转载请注明出处:效果有点类似VS2012安装界面

关键词:

上一篇:没有了
下一篇:没有了