自定义clickonce下载屏幕 [英] Customize clickonce download screen

查看:64
本文介绍了自定义clickonce下载屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯,这是众所周知的事实,当我们双击已安装的clickonce应用程序时,会弹出一个 clickonce屏幕,显示正在验证系统要求。然后,如果服务器中有更新的版本,请单击一次更新本地安装的版本,然后启动应用程序。有什么办法可以定制整个过程。这并不意味着我要对安装/升级部分进行某些操作,而只是想更改整个操作的GUI。
如屏幕上显示正在启动应用程序....以及不确定的进度条之类的东西就可以了。该屏幕应该代替所有clickonce弹出窗口,但允许clickonce在后台执行实际操作。
这类初始屏幕是我的意思,但是它覆盖了clickonce屏幕的GUI ...
任何建议?

Well, its a known fact that when we double-click on the clickonce installed application, a "clickonce screen" saying "Verifying system requirements" pops up. And then if there is an updated version in the server, clickonce updates the local installed version, and launches the application. Is there any way to customize this whole process. That doesn't mean that I want to do something with the installation/up-gradation part, I just want to change the GUI of this whole thing. Some thing like a screen which says "Starting the application...." along with an indefinite progress bar would be fine. This screen should come in place of all the clickonce pop-ups yet allowing clickonce to do the actual things in background. Kind-of splash screen is what I meant, but which overrides the GUI of clickonce screens... Any suggestions???

推荐答案

可以使用 ApplicationDeployment 类以编程方式更新应用程序。但是在这种情况下,您应该实现更新逻辑,根据问题,该逻辑可能是简单的也可能是复杂的。

There is a possibility to update the application progammatically, by using ApplicationDeployment class. But in this case you should implement update logic, which might be simple or sophisticated according the problem.

如果您以编程方式破解和下载更新,则可以取消选中更新发布窗口中的选项,即应用程序将不会被ClickOnce更新,并将执行您编写的所有更新逻辑。在代码中,您可以添加初始屏幕并同步更新,也可以添加一些动力学,并使用 CheckForDetailedUpdate 方法提供的数据让用户知道更新的进度。

In case you are chacking and downloading updates programmatically, you can uncheck the update option in "Publish" window, i.e. the application will not be updated by ClickOnce and will do all the updating logic you write. In code you can add splash screen and update synchronously or add some "dynamics" and let the user know the progress of the update using the data provided by CheckForDetailedUpdate method.

小样本:

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        bool isUpdated = tryUpdateApplication();

        if (isUpdated)
        {
            Application.Restart();
        }
        else
        {
            Application.Run(new MainForm());
        }
    }

    static bool tryUpdateApplication()
    {
        bool result = false;

        try
        {
            UpdateCheckInfo info = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate();

            if (info.UpdateAvailable)
            {
                //Show what you want to show
                ApplicationDeployment.CurrentDeployment.Update();
                //Hide what you showed
                result = true;
            }
        }
        catch (Exception ex) //better to catch the specific exceptions
        {
            //some exception handling logic
        }

        return result;
    }

这篇关于自定义clickonce下载屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆