Пример #1
0
        static void StatePropertyChanged(DependencyObject source,
                                         DependencyPropertyChangedEventArgs e)
        {
            TaskDialogProgressBar      progressBar = source as TaskDialogProgressBar;
            TaskDialogProgressBarState state       = (TaskDialogProgressBarState)e.NewValue;

            if (progressBar != null)
            {
                // Get progress bar owner task dialog
                TaskDialog owner = progressBar.Owner;

                if (owner != null)
                {
                    // Send update message only if the owner task dialog has a progress bar and
                    // is activated
                    if (owner.HasProgressBar && owner.IsActivated)
                    {
                        progressBar.SetProgressBarState(state);
                    }
                }
            }
        }
Пример #2
0
        static Object CoerceValueProperty(DependencyObject source, Object value)
        {
            TaskDialogProgressBar progressBar = source as TaskDialogProgressBar;
            Int32 v = (Int32)value;

            if (progressBar != null)
            {
                // Value cannot be smaller than the current minimum
                if (v < progressBar.Minimum)
                {
                    v = progressBar.Minimum;
                }

                // Value cannot be larger than the current maximum
                if (v > progressBar.Maximum)
                {
                    v = progressBar.Maximum;
                }
            }

            return(v);
        }
Пример #3
0
        static void RunMarqueePropertyChanged(DependencyObject source,
                                              DependencyPropertyChangedEventArgs e)
        {
            TaskDialogProgressBar progressBar = source as TaskDialogProgressBar;
            Boolean runMarquee = (Boolean)e.NewValue;

            if (progressBar != null)
            {
                // Get progress bar owner task dialog
                TaskDialog owner = progressBar.Owner;

                if (owner != null)
                {
                    // Send update message only if the owner task dialog has a progress bar and
                    // is activated
                    if (owner.HasProgressBar && owner.IsActivated)
                    {
                        progressBar.SetProgressBarMarquee(runMarquee, progressBar.MarqueeInterval);
                    }
                }
            }
        }
Пример #4
0
        static Object CoerceMinimumProperty(DependencyObject source, Object value)
        {
            TaskDialogProgressBar progressBar = source as TaskDialogProgressBar;
            Int32 minimum = (Int32)value;

            if (progressBar != null)
            {
                // Minimum cannot be larger than or equal maximum
                if (minimum >= progressBar.Maximum)
                {
                    minimum = progressBar.Minimum + 1;
                }
            }

            // Minimum cannot be smaller than Int16.MinValue
            // Restricted by the underlying native API
            if (minimum < Int16.MinValue)
            {
                minimum = Int16.MinValue;
            }

            return(minimum);
        }
Пример #5
0
        static void ValuePropertyChanged(DependencyObject source,
                                         DependencyPropertyChangedEventArgs e)
        {
            TaskDialogProgressBar progressBar = source as TaskDialogProgressBar;
            Int32 value = (Int32)e.NewValue;

            if (progressBar != null)
            {
                // Get progress bar owner task dialog
                TaskDialog owner = progressBar.Owner;

                if (owner != null)
                {
                    // Send update message only if the owner task dialog has a progress bar and
                    // is activated
                    if (owner.HasProgressBar && owner.IsActivated)
                    {
                        progressBar.SetProgressBarValue(value);
                        // Notify value changed
                        progressBar.OnValueChanged();
                    }
                }
            }
        }