예제 #1
0
        private void MakeFive(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            TextBlock txtb = new TextBlock();

            txtb.Text = "ProgressBar with five iterations.";
            sbar.Items.Add(txtb);
            Image       image = new Image();
            BitmapImage bi    = new BitmapImage();

            bi.BeginInit();
            bi.UriSource = new Uri(@"pack://application:,,,/data/sunset.png");
            bi.EndInit();
            image.Source = bi;
            ImageBrush imagebrush = new ImageBrush(bi);

            ProgressBar progbar = new ProgressBar();

            progbar.Background = imagebrush;
            progbar.Width      = 150;
            progbar.Height     = 15;
            Duration        duration        = new Duration(TimeSpan.FromMilliseconds(2000));
            DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);

            doubleanimation.RepeatBehavior = new RepeatBehavior(5);
            progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
            sbar.Items.Add(progbar);
        }
예제 #2
0
        private static void NavBarText_MouseLeave(object sender, MouseEventArgs e, NavBarLeftSide navBar, Grid grid, ProgressBar progressBar)
        {
            Duration        duration        = new Duration(TimeSpan.FromMilliseconds(300));
            DoubleAnimation doubleanimation = new DoubleAnimation(progressBar.Value - 100, duration);

            progressBar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
        }
예제 #3
0
        public static void SetPercent(this ProgressBar progressBar, double percentage, double durationInSecs = 2)
        {
            TimeSpan        duration  = TimeSpan.FromSeconds(durationInSecs);
            DoubleAnimation animation = new DoubleAnimation(percentage, duration.Duration());

            progressBar.BeginAnimation(ProgressBar.ValueProperty, animation);
        }
예제 #4
0
        private void MyProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            ProgressWorker w = (ProgressWorker)sender;

            pbar.BeginAnimation(System.Windows.Controls.ProgressBar.ValueProperty, null);
            pbar.Value = e.ProgressPercentage;
        }
예제 #5
0
        public void GetProgress(string path, string projectID, ProgressBar Bar = null)
        {
            TaskList.Clear();
            string query = $"SELECT COUNT(ID) FROM TASKS WHERE FK_ID = {Int32.Parse(projectID)}";

            TaskList = GetValue(query, path);
            string all = TaskList[0];

            query    = $"SELECT COUNT(ID) FROM TASKS WHERE FK_ID = {Int32.Parse(projectID)} AND STATUS = 'INACTIVE'";
            TaskList = GetValue(query, path);
            string inactive = TaskList[0];

            progressValue = Math.Round(((Double.Parse(inactive) / Double.Parse(all)) * 100), 0);

            try
            {
                Bar.Value = Convert.ToDouble(progressValue);
            }
            catch
            {
                Bar.Value     = 0;
                progressValue = 0;
            }
            finally
            {
                Duration        duration        = new Duration(TimeSpan.FromSeconds(0.7));
                DoubleAnimation doubleanimation = new DoubleAnimation(Convert.ToDouble(progressValue), duration);
                doubleanimation.DecelerationRatio = 0.70;
                Bar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
            }
        }
예제 #6
0
        public static void showDetails(string name, int wins, int defeats, int kills, int deaths)
        {
            if (dataPanel.Visibility == Visibility.Hidden)
            {
                dataPanel.Visibility = Visibility.Visible;
            }
            //Set labels
            kdRatioLabel.Content  = kills + " / " + deaths;
            wdRatioLabel.Content  = wins + " / " + defeats;
            statsForLabel.Content = "Statistics for " + name;

            //Set maximums
            kdRatioBar.Maximum = kills + deaths;
            wdRatioBar.Maximum = wins + defeats;
            //Set animation duration
            Duration duration = new Duration(TimeSpan.FromSeconds(1));
            //Begin animation for KDbar
            DoubleAnimation kdValueAnim = new DoubleAnimation(kills, duration);

            kdRatioBar.BeginAnimation(ProgressBar.ValueProperty, kdValueAnim);
            //Begin animation for WDbar
            DoubleAnimation wdValueAnim = new DoubleAnimation(wins, duration);

            wdRatioBar.BeginAnimation(ProgressBar.ValueProperty, wdValueAnim);
        }
예제 #7
0
        private void ChangeProgressBarValueOnUnload(ProgressBar bar, int value)
        {
            Duration        duration        = new Duration(TimeSpan.FromMilliseconds(1));
            DoubleAnimation doubleanimation = new DoubleAnimation(value, duration);

            bar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
        }
예제 #8
0
        public static void SetPercentValueWithAnimation(this ProgressBar progressBar, double percent, TimeSpan duration)
        {
            double newValue = (progressBar.Maximum * percent / 100);

            DoubleAnimation animation = new DoubleAnimation(newValue, duration);

            progressBar.BeginAnimation(ProgressBar.ValueProperty, animation);
        }
예제 #9
0
        public void StartCountDown(bool isMainPlayer, int timeOutSeconds)
        {
            ProgressBar progressBar = isMainPlayer ? progressBar1 : progressBar2;

            if (timeOutSeconds == 0)
            {
                progressBar.Visibility = System.Windows.Visibility.Hidden;
                progressBar.BeginAnimation(ProgressBar.ValueProperty, null);
            }
            else
            {
                progressBar.Visibility = System.Windows.Visibility.Visible;
                progressBar.Opacity    = 1.0d;

                Duration        duration        = new Duration(TimeSpan.FromSeconds(timeOutSeconds));
                DoubleAnimation doubleanimation = new DoubleAnimation(100d, 0d, duration);
                progressBar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
            }
        }
예제 #10
0
        /// <summary>
        /// 使用线性动画设置 Progress Bar 的值
        /// </summary>
        /// <param name="progressBar">Progress Bar</param>
        /// <param name="percentage">值</param>
        public static void SetPercent(this ProgressBar progressBar, double percentage)
        {
            DoubleAnimation animation = new DoubleAnimation(percentage, TimeSpan.FromMilliseconds(300))
            {
                AccelerationRatio = 0,
                DecelerationRatio = 0.6
            };

            progressBar.BeginAnimation(System.Windows.Controls.Primitives.RangeBase.ValueProperty, animation);
        }
예제 #11
0
        /// <summary>
        /// 使用线性动画设置 Progress Bar 的值
        /// </summary>
        /// <param name="progressBar">Progress Bar</param>
        /// <param name="percentage">值</param>
        /// <param name="percentage">持续时间</param>
        public static void SetPercent(this ProgressBar progressBar, double percentage, Duration duration)
        {
            DoubleAnimation animation = new DoubleAnimation(percentage, duration);

            animation.Completed += (obj, args) =>
            {
                progressBar.Value = percentage;
            };
            progressBar.BeginAnimation(System.Windows.Controls.Primitives.RangeBase.ValueProperty, animation);
        }
예제 #12
0
        /// <summary>
        /// 以动画形式将进度条过渡到新的值
        /// </summary>
        /// <param name="value"></param>
        public void SetNewProgress(double value)
        {
            DoubleAnimation doubleAnimation = new DoubleAnimation
            {
                To       = value,
                Duration = new Duration(TimeSpan.FromMilliseconds(500))
            };

            ProgressBar.BeginAnimation(MetroProgressBar.ValueProperty, doubleAnimation);
        }
예제 #13
0
        private void DoWakeupRoutine()
        {
            ProgressBar.BeginAnimation(OpacityProperty, new DoubleAnimation(1.0, 0, TimeSpan.FromSeconds(2)));
            //Fade out progress bar

            _musicPlayer.InitAudioAsset("Intro.wav", false); //Init intro music.
            _musicPlayer.PlayMusic();                        //Play

            LoadBackgroundImages();

            LoadWeatherTiles();
        }
예제 #14
0
 public void UpdateValue(double value)
 {
     if (value - ProgressBar.Value <= 1) //if value not changed or changed by 1
     {
         ProgressBar.Value = value;
     }
     else
     {
         DoubleAnimation animation = new(value, TimeSpan.FromMilliseconds(100)); //time is the same as in "ProgressUpdater()"
         ProgressBar.BeginAnimation(ProgressBar.ValueProperty, animation);       //smooth progress change
     }
 }
예제 #15
0
        private void CreateDynamicProgressBarControl()
        {
            ProgressBar PBar2 = new ProgressBar();

            PBar2.IsIndeterminate = false;
            PBar2.Orientation     = Orientation.Horizontal;
            PBar2.Width           = 200;
            PBar2.Height          = 20;
            Duration        duration        = new Duration(TimeSpan.FromSeconds(20));
            DoubleAnimation doubleanimation = new DoubleAnimation(200.0, duration);

            PBar2.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
            SBar.Items.Add(PBar2);
        }
예제 #16
0
        private void OnFlipViewSelectionChanged_(object sender, SelectionChangedEventArgs e)
        {
            ProgressBar.SetPercent(0, TimeSpan.Zero);

            m_dispatcherTimer.Stop();
            m_dispatcherTimer.Start();

            // we have to clear the animation here, as we can't update the value while it's
            // still animating
            ProgressBar.BeginAnimation(MetroProgressBar.ValueProperty, null);

            // restart the animation
            ProgressBar.SetPercent(100, m_timePerPageSeconds);
        }
예제 #17
0
        private void createprogressbar()
        {
            ProgressBar pb2 = new ProgressBar();

            pb2.IsIndeterminate = false;
            pb2.Orientation     = Orientation.Horizontal;
            pb2.Width           = 100;
            pb2.Height          = 25;
            //loadprogressbar();
            Duration        dur    = new Duration(TimeSpan.FromSeconds(30));
            DoubleAnimation dblani = new DoubleAnimation(200.0, dur);

            pb2.BeginAnimation(ProgressBar.ValueProperty, dblani);
            sbar1.Items.Add(pb2);
        }
예제 #18
0
        private void createProgressBar(int i)
        {
            ProgressBar ProgStatusBar = new ProgressBar();

            ProgStatusBar.IsIndeterminate = false;
            ProgStatusBar.Orientation     = Orientation.Horizontal;
            ProgStatusBar.Width           = 400;
            ProgStatusBar.Height          = 25;

            Duration        dur     = new Duration(TimeSpan.FromSeconds(30));
            DoubleAnimation dblAnim = new DoubleAnimation(200.0, dur);

            ProgStatusBar.BeginAnimation(ProgressBar.ValueProperty, dblAnim);
            ProgStatusBar.Value = i;
            StatusBar.Items.Add(ProgStatusBar);
        }
예제 #19
0
        public void SetProgress(double CurrentLength)
        {
            double Progress = CurrentLength / ProgressBar.Maximum * 100;

            ProgressText.Text = Progress.ToString("0.0") + "%";
            ProgressBar.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation()
            {
                From           = ProgressBar.Value,
                To             = CurrentLength,
                Duration       = TimeSpan.FromSeconds(0.2),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseInOut
                }
            });
        }
        private async Task ShowProgressbar()
        {
            await Task.Delay(1);

            var outAnimation = new DoubleAnimation
            {
                To           = 1,
                BeginTime    = TimeSpan.FromSeconds(0),
                Duration     = TimeSpan.FromMilliseconds(100),
                FillBehavior = FillBehavior.Stop
            };

            outAnimation.Completed += (s, a) => ProgressBar.Opacity = 1;

            ProgressBar.BeginAnimation(UIElement.OpacityProperty, outAnimation);
        }
예제 #21
0
        public void SetProgressBarValue(double value)
        {
            if (progressBar != null)
            {
                if (value > 100)
                {
                    value = 100;
                }
                else if (value < 0)
                {
                    value = 0;
                }

                Duration duration = new Duration(TimeSpan.FromSeconds(0.5));
                progressBar.BeginAnimation(ProgressBar.ValueProperty, new DoubleAnimation(value, duration));
            }
        }
예제 #22
0
        private void uploadBinary(string db, string executable)
        {
            haveBinId = false;

            WindowInteropHelper helper = new WindowInteropHelper(this);
            SubmissionWorker    w      = new SubmissionWorker(helper.Handle, workers.Count());

            w.DoWork                    += new DoWorkEventHandler(worker_DoWork);
            w.ProgressChanged           += new ProgressChangedEventHandler(worker_ProgressChanged);
            w.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            w.WorkerReportsProgress      = true;
            w.WorkerSupportsCancellation = false;

            RowDefinition row = new RowDefinition();

            outerGrid.RowDefinitions.Add(row);
            row.Height = new GridLength(26);
            Label l = new Label();

            l.Content = "Upload binary...";
            l.Height  = 26;
            Grid.SetRow(l, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(l, 0);
            outerGrid.Children.Add(l);

            ProgressBar p = new ProgressBar();

            p.Height = 26;
            p.Width  = 75;
            Grid.SetRow(p, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(p, 1);
            outerGrid.Children.Add(p);

            DoubleAnimation a = new DoubleAnimation(0.0, 100.0, new Duration(TimeSpan.FromSeconds(1)));

            a.RepeatBehavior = RepeatBehavior.Forever;
            a.AutoReverse    = true;
            p.BeginAnimation(System.Windows.Controls.ProgressBar.ValueProperty, a);

            pbars.Add(w.id, p);
            Object[] args = { "Upload", db, executable };
            workers.Add(w.id, w);
            w.RunWorkerAsync(args);
        }
예제 #23
0
        private void MakeForever(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            Label lbl = new Label();

            lbl.Background = new LinearGradientBrush(Colors.LightBlue,
                                                     Colors.SlateBlue, 90);
            lbl.Content = "ProgressBar with infinite iterations.";
            sbar.Items.Add(lbl);
            ProgressBar progbar = new ProgressBar();

            progbar.Width  = 150;
            progbar.Height = 15;
            Duration        duration        = new Duration(TimeSpan.FromSeconds(1));
            DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);

            doubleanimation.RepeatBehavior = RepeatBehavior.Forever;
            progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
            sbar.Items.Add(progbar);
        }
예제 #24
0
        private void MakeOne(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            Label lbl = new Label();

            lbl.Background = new LinearGradientBrush(Colors.LightBlue, Colors.SlateBlue, 90);
            lbl.Content    = "ProgressBar with one iteration.";
            sbar.Items.Add(lbl);
            ProgressBar progbar = new ProgressBar();

            progbar.IsIndeterminate = false;
            progbar.Orientation     = Orientation.Horizontal;
            progbar.Width           = 150;
            progbar.Height          = 15;
            Duration        duration        = new Duration(TimeSpan.FromSeconds(10));
            DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);

            progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
            sbar.Items.Add(progbar);
        }
예제 #25
0
        private void MakeThree(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            Label lbl = new Label();

            lbl.Background = new LinearGradientBrush(Colors.Pink, Colors.Red, 90);
            lbl.Content    = "ProgressBar with three iterations.";
            sbar.Items.Add(lbl);
            ProgressBar progbar = new ProgressBar();

            progbar.Background = Brushes.Gray;
            progbar.Foreground = Brushes.Red;
            progbar.Width      = 150;
            progbar.Height     = 15;
            Duration        duration        = new Duration(TimeSpan.FromMilliseconds(2000));
            DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);

            doubleanimation.RepeatBehavior = new RepeatBehavior(3);
            progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
            sbar.Items.Add(progbar);
        }
        public void ProgressBarExecuter()
        {
            ProgressBar progressBar = new ProgressBar();

            progressBar.IsIndeterminate = false;
            progressBar.Orientation     = Orientation.Horizontal;
            progressBar.Width           = 300;
            progressBar.Height          = 25;

            Duration        duration    = new Duration(TimeSpan.FromSeconds((4)));
            DoubleAnimation doubleAnima = new DoubleAnimation(200, duration);

            statusBar1.Items.Add(progressBar);

            TaskScheduler uiThread = TaskScheduler.FromCurrentSynchronizationContext();

            Action MainThreadDoWork = new Action(() =>
            {
                Thread.Sleep(4000);
            });

            Action ExecuteProgressBar = new Action(() =>
            {
                progressBar.BeginAnimation(ProgressBar.ValueProperty, doubleAnima);
            });

            Action FinalThreadDoWork = new Action(() =>
            {
                statusBar1.Items.Remove(progressBar);
                this.Close();
            });

            Task MainThreadDoWorkTask = Task.Factory.StartNew(() => MainThreadDoWork());

            Task ExecuteProgressBarTask = new Task(ExecuteProgressBar);

            ExecuteProgressBarTask.RunSynchronously();

            MainThreadDoWorkTask.ContinueWith(t => FinalThreadDoWork(), uiThread);
        }
        private void StartProgressBar(string msg)
        {
            this.sbar.Items.Clear();
            Label label = new Label();

            label.Content = msg;
            this.sbar.Items.Add(label);
            ProgressBar progressBar = new ProgressBar();

            progressBar.Width = base.Width - 200.0;
            if (progressBar.Width < 10.0)
            {
                progressBar.Width = 250.0;
            }
            progressBar.Height = 15.0;
            Duration        duration        = new Duration(TimeSpan.FromSeconds(8.0));
            DoubleAnimation doubleAnimation = new DoubleAnimation(100.0, duration);

            doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
            progressBar.BeginAnimation(RangeBase.ValueProperty, doubleAnimation);
            this.sbar.Items.Add(progressBar);
        }