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); }
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); }
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); }
private void MyProgressChanged(object sender, ProgressChangedEventArgs e) { ProgressWorker w = (ProgressWorker)sender; pbar.BeginAnimation(System.Windows.Controls.ProgressBar.ValueProperty, null); pbar.Value = e.ProgressPercentage; }
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); } }
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); }
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); }
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); }
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); } }
/// <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); }
/// <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); }
/// <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); }
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(); }
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 } }
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); }
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); }
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); }
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); }
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); }
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)); } }
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); }
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); }
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); }
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); }