private void Thumb_PreviewMouseMove(object sender, MouseEventArgs e) { try { if (isCaptured) { if (e.LeftButton == MouseButtonState.Pressed) { if (!(e.GetPosition(this).X - Thumb.ActualWidth / 2 >= Bg.ActualWidth - Thumb.ActualWidth / 2 + 26)) { if (!(e.GetPosition(this).X - Thumb.ActualWidth / 2 <= 25 - Thumb.ActualWidth / 2 - 1)) { ThumbMove.Margin = new Thickness(e.GetPosition(this).X - Thumb.ActualWidth / 2 - 25, 0, 0, 0); Progress.Width = e.GetPosition(this).X + Thumb.ActualWidth / 2 - 25; Animations.AnimateMargin(new Thickness(ValueLabel.Margin.Left, -4, 0, -2), new Thickness(e.GetPosition(this).X - Thumb.ActualWidth / 2 - 26, -4, 0, 4), ValueLabel, 0, 0, null); ValueLabel.Margin = new Thickness(e.GetPosition(this).X - Thumb.ActualWidth / 2 - 26, -4, 0, 4); Panel.SetZIndex(Thumb, Int32.MaxValue); Value = (int)Procent.procentX(Bg.ActualWidth, e.GetPosition(this).X - 25); Val.Text = Value + ""; } } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
private void AnimateWidth() { double w = Procent.intX(width, progress); Animations.AnimateWidth(lasttime, w, Divider, time, 0, null); lasttime = w; }
private void UpdateValues() { Dispatcher.Invoke(() => { Progress.Width = Procent.intX(Bg.ActualWidth, Value); Animations.AnimateMargin(ValueLabel.Margin, new Thickness(Procent.intX(Bg.ActualWidth, Value) - Thumb.ActualWidth / 2, ValueLabel.Margin.Top, ValueLabel.Margin.Right, ValueLabel.Margin.Bottom), ValueLabel, 0, 0, null); Val.Text = Value + ""; ThumbMove.Margin = new Thickness(Procent.intX(Bg.ActualWidth, Value) - Thumb.ActualWidth / 2, 0, 0, 0); }); }
private void Thumb_SizeChanged(object sender, SizeChangedEventArgs e) { try { ThumbMove.Margin = new Thickness(Procent.intX(Bg.ActualWidth, Value) - Thumb.ActualWidth / 2, 0, 0, 0); Progress.Width = Procent.intX(Bg.ActualWidth, Value); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public void SetProgressWidth(double p) { progress = Procent.procentX(width, p); AnimateWidth(); }
public double GetProgressWidth() { return(Procent.intX(width, progress)); }