Пример #1
0
        /// <summary>
        /// Initialize the progress indicator visual using the specified viewModel.
        /// </summary>
        /// <param name="viewModel">View model.</param>
        public static void Initialize(ProgressIndicatorViewModel viewModel)
        {
            var owner             = SingleInstanceApplication.Current.MainWindow;
            var progressIndicator = new ProgressIndicator(viewModel, owner);

            owner.SetValue(ProgressIndicatorVisualPropertyName, progressIndicator);
        }
Пример #2
0
        private ProgressIndicator(ProgressIndicatorViewModel viewModel, Gtk.Window owner)
            : base(Gtk.WindowType.Toplevel)
        {
#if ENABLE_OVERLAY
            _overlay = new ProgressIndicatorOverlay(owner);
#endif // ENABLE_OVERLAY
            _pulseTimer                = new OSDispatcherTimer();
            _pulseTimer.Interval       = System.TimeSpan.FromMilliseconds(TimerTickMilliseconds);
            _pulseTimer.Tick          += Pulse;
            DataContext                = viewModel;
            viewModel.PropertyChanged += HandlePropertyChanged;
            this.Build();
            this.DefaultHeight = -1;
            _cancel.Label      = ProgressIndicatorViewModel.Cancel;
        }
Пример #3
0
        /// <summary>
        /// Creates a new instance of AsyncTaskWithProgress.
        /// </summary>
        /// <param name="taskName">The name of the task, which will be shown above the progress indicator.</param>
        /// <param name="allowsCancel">If <c>true</c>, indicates that a 'Cancel' button should be available, allowing the user to cancel the operation.</param>
        /// <param name="isIndeterminate">If <c>true</c>, indicates the task will not indicate a percentage done, but rather that the task is 'alive'.</param>
        /// <param name="showsProgress">If <c>true</c>, indicates the task will show progress bar after appropriate time passes, otherwise no progress bar will be shown.</param>
        /// <param name="progressDisplayDelay">How long to wait (in seconds) before showing the progress bar.</param>
        public AsyncTaskWithProgress(string taskName, bool allowsCancel, bool isIndeterminate, bool showsProgress, double progressDisplayDelay)
        {
            _showsProgress = showsProgress;
            if (_showsProgress)
            {
                _progressIndicator = ProgressIndicatorViewModel.ApplicationProgressIndicator;
                if (_progressIndicator != null)
                {
                    _progressIndicator.DisplayDelay = progressDisplayDelay;
                    _progressIndicator.Title = taskName;
                    _progressIndicator.IsIndeterminate = isIndeterminate;
                    _progressIndicator.AllowsCancel = allowsCancel;
                    _progressIndicator.UpdateText = string.Empty;
                }
            }
#if USE_ASYNC
            _backgroundWorker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = allowsCancel };
            _backgroundWorker.DoWork += AsyncTaskDoWork;
            _backgroundWorker.ProgressChanged += AsyncTaskProgressChanged;
            _backgroundWorker.RunWorkerCompleted += AsynTaskRunWorkerCompleted;
#endif // USE_ASYNC
        }