@@ -464,6 +464,21 @@ public static Form ProgressForm {
464464 }
465465 }
466466
467+ // with form progress, style and state are both stored in one field
468+ // setting marquee style enters indeterminate state
469+ // you can't display marquee style and normal/error/paused state at the same time
470+ // so error/paused states take priority over the marquee style
471+ // and marquee style takes priority over normal state
472+ // furthermore, when the value is completed we enter the no progress state, which
473+ // takes priority over all other states
474+ // when the value is completed, setting the state to error/paused should do nothing
475+ // until the value is reset, in which case it should show the error/paused state
476+ // when the value is completed, setting the style to marquee should do nothing
477+ // until the value is reset, in which case it should show marquee style
478+ // (but only if not in the error/paused states)
479+ // when the value is completed, setting the state to normal should do nothing
480+ // until the value is reset, in which case it should show normal state
481+ // (but only if not in the error/paused states or marquee style)
467482 private static ProgressBarStyle ProgressFormStyle {
468483 /*
469484 get {
@@ -472,28 +487,37 @@ private static ProgressBarStyle ProgressFormStyle {
472487 */
473488
474489 set {
490+ // if the style is not marquee
475491 if ( value != ProgressBarStyle . Marquee ) {
492+ // do nothing if we have already left indeterminate state
476493 if ( ProgressManager . progressFormState != TBPF . TBPF_INDETERMINATE ) {
477494 return ;
478495 }
479-
496+
497+ // leave indeterminate state
480498 ProgressFormValue = ProgressManager . value ;
481- ProgressFormState = ProgressManager . state ;
499+ return ;
500+ }
501+
502+ // this happens here so we don't enter indeterminate state
503+ // if we're completed
504+ // otherwise when the value is reset and updates the style
505+ // it'll be ignored because we aren't in normal/no progress states
506+ // if we're in indeterminate state, it must be shown
507+ if ( ProgressManager . progressFormValue >= PROGRESS_FORM_VALUE_COMPLETE ) {
482508 return ;
483509 }
484510
485511 // only enter indeterminate state from normal/no progress states
512+ // we enter from no progress in case the value was reset
513+ // error/paused states take priority over indeterminate state
486514 if ( ProgressManager . progressFormState != TBPF . TBPF_NORMAL
487515 && ProgressManager . progressFormState != TBPF . TBPF_NOPROGRESS ) {
488516 return ;
489517 }
490518
491519 ProgressManager . progressFormState = TBPF . TBPF_INDETERMINATE ;
492520
493- if ( ProgressManager . progressFormValue >= PROGRESS_FORM_VALUE_COMPLETE ) {
494- return ;
495- }
496-
497521 if ( ProgressForm == null ) {
498522 return ;
499523 }
@@ -564,8 +588,10 @@ private static int ProgressFormValue {
564588 return ;
565589 }
566590
567- // if we previously completed, update the state
568- if ( ProgressManager . progressFormState == TBPF . TBPF_NOPROGRESS ) {
591+ // if we are here, we are not completed, and, we are not marquee style
592+ // so if we were previously no progress or indeterminate state, update the state
593+ if ( ProgressManager . progressFormState == TBPF . TBPF_NOPROGRESS
594+ || ProgressManager . progressFormState == TBPF . TBPF_INDETERMINATE ) {
569595 ProgressFormState = ProgressManager . state ;
570596 }
571597 }
@@ -585,6 +611,15 @@ private static IntPtr ProgressFormState {
585611 */
586612
587613 set {
614+ // this happens here so we don't enter error/paused state
615+ // if we're completed
616+ // otherwise when the value is reset and updates the state
617+ // it'll be ignored because we are in error/paused state
618+ // if we're in error/paused state, it must be shown
619+ if ( ProgressManager . progressFormValue >= PROGRESS_FORM_VALUE_COMPLETE ) {
620+ return ;
621+ }
622+
588623 if ( value == PBST_ERROR ) {
589624 if ( ProgressManager . progressFormState == TBPF . TBPF_ERROR ) {
590625 return ;
@@ -610,10 +645,6 @@ private static IntPtr ProgressFormState {
610645
611646 ProgressManager . progressFormState = TBPF . TBPF_NORMAL ;
612647 }
613-
614- if ( ProgressManager . progressFormValue >= PROGRESS_FORM_VALUE_COMPLETE ) {
615- return ;
616- }
617648
618649 if ( ProgressForm == null ) {
619650 return ;
0 commit comments