文档章节

How to create progress indicators

fandyx
 fandyx
发布于 2015/01/15 09:16
字数 839
阅读 12
收藏 0

Use a progress indicator during operations that take more than 2 seconds.

  • Use an hourglass mouse pointer if the process takes 2-7 seconds.

  • Use a progress bar if the process takes 8 seconds or more.

Display an Hourglass Pointer


  1. Call the startLengthyOperation method when the operation starts.

  2. Call the endLengthyOperation method when the operation ends.

Both of these methods are on the Global application class.

The hourglass pointer is displayed until you call the endLengthyOperation method.

NoteNOTE
You do not have to declare a variable when you use the Global class.

EXAMPLE: DISPLAY AN HOURGLASS POINTER

The following example overrides the clicked method on a form control to refresh the database log.

Copy

void clicked()
{
    super();
    startLengthyOperation();
    sysDatabaseLog_ds.research();
    endLengthyOperation();
}

Display a Progress Bar


  1. Initialize a SysOperationProgress variable.

  2. Set a caption for the form by using the SysOperationProgress.setCaption method.

  3. Set an animation to run while the operation is in progress by using the SysOperationProgress.setAnimation method.A number of animations are provided with Microsoft Dynamics AX. To view them, run the Tutorial_ShowAVIFiles class. If you use one of these animation files, you need to declare the AviFiles macro at the top of your code.

  4. Specify the total number of operation steps.This is needed for the time-remaining calculation. If you do not set the total number of operation steps, the progress indicator is not shown. The total is often a count of the number of records, and may be time-consuming to calculate. Don’t specify the total if the time is taken to calculate the records is comparable to the total time taken for the operation.

  5. Perform the operation. For each step, specify a description and a step number. For example:

    Copy

    for (i = 1; i <= 100; i++)
    {
        progress.setText(strfmt("Step %1", i));
        progress.incCount();
    }

    The description must be short and informative because it might change quickly during the execution.

    As an alternative to incCount() you can use setCount(int i).

During the execution, the progress indicator is updated accordingly. The estimated time remaining is calculated and displayed.

The default update interval is 3 seconds. If the task of updating the display takes more than 10% of the update interval due to latency on the network connection, the update interval is increased by 1 second.

TipTIP
Separate an operation into as many steps as possible. This gives the user the best information and the best remaining-time estimate. The time spent informing the user has no impact because the form is updated only once a second—even less frequently on low bandwidth connections.

EXAMPLE: USE A SINGLE PROGRESS INDICATOR

The following example creates a simple progress indicator.

Copy

static void operationProgress(Args _args)
{
    #AviFiles
    SysOperationProgress progress = new SysOperationProgress();
    int i;

    ;

    progress.setCaption("My Task");
    progress.setAnimation(#AviUpdate);
    progress.setTotal(30000);
    for (i = 1; i <= 30000; i++)
    {
        progress.setText(strfmt("Step %1", i));
        progress.setCount(i, 1);
    }
}

Use More Than One Progress Indicator


If you have a more complex operation, you can have more than one progress indicator. All of the previously described methods have a default parameter that indicates which progress indicator (or bar) is being referred to.

NoteNOTE
The time-remaining calculation is done solely on the first bar. The first bar must always show the overall progress.

EXAMPLE: USE THREE PROGRESS INDICATORS

Copy

static void SysOperationProgress(Args _args)
{
    #define.count1(10)
    #define.count2(5)
    #define.count3(200)
    #AviFiles

    // 3 bars.
    SysOperationProgress progress = new SysOperationProgress(3);
    int i, j, k;
    ;

    progress.setCaption("My Task");
    progress.setAnimation(#AviUpdate);

    // Bar 1.
    progress.setTotal(#count1, 1);
    // Bar 2.
    progress.setTotal(#count2, 2);
    // Bar 3.
    progress.setTotal(#count3, 3);

    for (i=0; i<#count1; i++)
    {
        // Bar 1.
        progress.setText(strfmt("Bar 1 - Step %1 of %2", i, #count1), 1);
        progress.setCount(i, 1);
        for (j=0; j<#count2; j++)
        {
            // Bar 2.
            progress.setText(strfmt("Bar 2 - Step %1 of %2", j, #count2), 2);
            progress.setCount(j, 2);
            for (k=0; k<#count3; k++)
            {
                // Bar 3.
                progress.setText(
                    strfmt("Bar 3 - Step %1 of %2", k, #count3), 3);
                progress.setCount(k, 3);
                sleep(20);      // Time-consuming task.
            }
        }
    }
}

User Input During an Operation


Following are progress indicator options for user input during an operation:

  • SysOperationProgress.hide – hides the progress form and pauses the time-remaining calculation. The progress indicator reappears when setCount, incCount, or setText is subsequently called.

  • SysOperationProgress.kill – terminates the progress form and starts the progress again. You don’t have to reset the caption, animation, and total.

Using Progress Indicators with the Runbase Framework


Runbase is the standard framework for job execution, and must have a progress indicator. In the standard application, most progress indicators are used from the RunBase framework.Use the RunBase.progressInit method to initialize the progress indicator:

Copy

public void progressInit(
    str       caption,
    int       total,
    Filename  animation,
    int       updateInterval = 1,
    int       numOfBars      = 1)

Indicating progress during the actual operation is similar to the standard Operation Progress framework. Use the member variable progress:

progress.incCount();

If you have more than one progress bar, use the progress variable defined in RunBase. It points to the Progress class initialized in the progressInit method. For example:

Copy

{
    this.progressInit("Caption",10,#AviFileCopy,1,2);
    progress.setCount(bar1count);
    progress.setTotal(maxBar2Count,bar2count);
    ...
    ...
    progress.setCount(bar2count,2);
}


© 著作权归作者所有

共有 人打赏支持
fandyx
粉丝 0
博文 39
码字总数 11111
作品 0
东莞
技术主管
datemaker

jquery.datamaker.js provides an easy way to create Javascript Date objects using simple time interval indicators. Use datamaker to create Data objects to use with jQuery cookie ......

匿名
2008/09/19
382
0
HyperSQL 2.6 发布

HyperSQL就像doxygen的程序,但只为SQL提供。它映射SQL视图,包,程序,以及HTML源代码清单的功能,显示所有的代码,这些功能对 应的代码。内部“where used”的功能还能够扫描C + +和Java源...

红薯
2010/04/01
86
0
MFC的状态栏CStatusBar编程

MFC的状态栏CStatusBar编程 1. 新建一个多文档的MFC应用程序; 2. 状态栏的定义:在CMainFrame类中定义,如下: protected: // control bar embedded members CStatusBar m_wndStatusBar; 3....

长平狐
2012/10/08
996
0
WPScan 1.1 发布,WordPress安全扫描器

WPScan是一款使用ruby编写、基于白盒测试的WordPress安全扫描器,它会尝试查找WordPress安装版的一些已知的安全弱点。WPScan可以辅助专业安全人员或是WordPress管理员评估他们的WordPress安装...

红薯
2011/11/28
1K
0
SciTE 3.4.4 发布

Release 3.4.4 Released 3 July 2014. Style byte indicators removed. They were deprecated in 2007. Standard indicators should be used instead. When multiple selections are active,......

雨里有条鱼
2014/07/03
1K
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

配置Spring的注解支持

声明:本栏目所使用的素材都是凯哥学堂VIP学员所写,学员有权匿名,对文章有最终解释权;凯哥学堂旨在促进VIP学员互相学习的基础上公开笔记。 配置Spring的注解支持 以上也提到了使用注解来配...

凯哥学堂
33分钟前
0
0
关于Spring Aop存在的一点问题的思考

在本人前面的文章Spring Aop原理之切点表达式解析中讲解了Spring是如何解析切点表达式的,在分析源码的时候,出现了如下将要讲述的问题,我认为是不合理的,后来本人单纯使用aspectj进行试验...

爱宝贝丶
35分钟前
0
0
JavaScript 概述

JavaScript是面向Web的编程语言。绝大多数现代网站都使用了JavaScript,并且所有的现代Web浏览器——基于桌面系统、游戏机、平板电脑和智能手机的浏览器——均包含了JavaScript解释器。这使得...

Mr_ET
今天
0
0
Java Run-Time Data Areas(Java运行时数据区/内存分配)

Java运行时数据区(内存分配) 本文转载官网 更多相关内容可查看官网 中文翻译可参考 2.5. Run-Time Data Areas The Java Virtual Machine defines various run-time data areas that are use...

lichuangnk
今天
0
0
docker learn :services docker-compose.yml

docker-compose.yml定义了服务的运行参数 version: "3" services: web: # replace username/repo:tag with your name and image details image: hub.c.163.com/dog948453219/friendlyhello d......

writeademo
今天
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部