Convert() public method

Converts the value in seconds to a label in the form MM:SS.
public Convert ( object value, Type targetType, object parameter, System culture ) : object
value object Time value in seconds
targetType System.Type Unused param
parameter object Unused param
culture System Unused param
return object
Exemplo n.º 1
0
        /// <summary>
        /// Mouse Enter event Handler that handles the visibility of the indicator
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Slider_MouseEnter(object sender, MouseEventArgs e)
        {
            Slider s       = sender as Slider;
            Point  p       = e.GetPosition(s);
            object cItem   = this.FindName("SliderCanvas");
            Canvas canvas  = cItem as Canvas;
            Point  globalP = e.GetPosition(canvas);
            double myTime  = (p.X / s.ActualWidth) * ((AudioPlayerModel)this.DataContext).Length;
            object item    = this.FindName("position_indicator");

            if ((item != null) && (item is PositionIndicator))
            {
                PositionIndicator indicator = item as PositionIndicator;
                indicator.Visibility = Visibility.Visible;
                indicator.SetValue(Canvas.LeftProperty, p.X - 16);
                object item_label = indicator.FindName("TimePositionLabel");
                if ((item_label != null) && (item_label is TextBlock))
                {
                    TextBlock       label     = item_label as TextBlock;
                    LengthConverter converter = new LengthConverter();
                    label.Text = (string)converter.Convert(myTime, typeof(string), null, null);
                    //Console.WriteLine(myTime);
                }
                //indicator.Margin = new Thickness(globalP.X, 0, 0, 0);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Mouse Enter event Handler that handles the visibility of the indicator
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Slider_MouseEnter(object sender, MouseEventArgs e)
 {
     Slider s = sender as Slider;
     Point p=e.GetPosition(s);
     object cItem = this.FindName("SliderCanvas");
     Canvas canvas = cItem as Canvas;
     Point globalP = e.GetPosition(canvas);
     double myTime = (p.X / s.ActualWidth) * ((AudioPlayerModel)this.DataContext).Length;
     object item = this.FindName("position_indicator");
     if ((item != null) && (item is PositionIndicator))
     {
         PositionIndicator indicator = item as PositionIndicator;
         indicator.Visibility = Visibility.Visible;
         indicator.SetValue(Canvas.LeftProperty,p.X-16);
         object item_label = indicator.FindName("TimePositionLabel");
         if ((item_label != null) && (item_label is TextBlock))
         {
             TextBlock label = item_label as TextBlock;
             LengthConverter converter = new LengthConverter();
             label.Text = (string)converter.Convert(myTime, typeof(string), null, null);
             //Console.WriteLine(myTime);
         }
         //indicator.Margin = new Thickness(globalP.X, 0, 0, 0);
     }
 }