public ContentAttributeExample()
        {
            var          pfcc    = new PathFigureCollectionConverter();
            const string Figures = "M 20,20 L 140,20 L 140,140 L 20,140 L 20,20 M 80,30 L 130,80 L 80,130 L 30,80 L 80,30 M 60,60 L 100,60 L 100,100 L 60,100 L 60,60 M 80,65 L 95,80 L 80,95 L 65,80 L 80,65";
            var          pfc     = (PathFigureCollection)pfcc.ConvertFrom(Figures);
            var          path    = new Path
            {
                Stroke             = Brushes.Blue,
                StrokeThickness    = 1.5,
                Fill               = Brushes.LightBlue,
                StrokeStartLineCap = PenLineCap.Square,
                StrokeEndLineCap   = PenLineCap.Square,
                Opacity            = 0.6,
                Data               = new PathGeometry(pfc)
                {
                    FillRule = FillRule.Nonzero
                }
            };

            var panel = new StackPanel();

            panel.Children.Add(new TextBlock {
                Text = "The ContentAttribute lets you mix text and figures. The figure is defined by\nM 20,20 L 140,20 L 140,140 L 20,140 L 20,20 M 80,30 L 130,80 L 80,130 L 30,80 L 80,30 M 60,60 L 100,60 L 100,100 L 60,100 L 60,60 M 80,65 L 95,80 L 80,95 L 65,80 L 80,65"
            });
            panel.Children.Add(path);
            this.Content1 = panel;
        }
示例#2
0
        private void RepeatButton_Click(object sender, RoutedEventArgs e)
        {
            Button but = sender as Button;

            if (!isRepeat && !Player.settings.getMode("loop"))
            {
                but.MouseLeave -= Button_MouseLeave;
                ((Path)but.FindName(but.Name + "Path")).Fill = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                PathGeometry pg = new PathGeometry();
                pg.FillRule = FillRule.Nonzero;
                PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter();
                pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4zm-4-2V9h-1l-2 1v1h1.5v4H13z");
                ((Path)but.FindName(but.Name + "Path")).Data = pg;
                Player.settings.setMode("loop", true);
            }
            else
            {
                Player.settings.setMode("loop", false);
                if (!isRepeat)
                {
                    PathGeometry pg = new PathGeometry();
                    pg.FillRule = FillRule.Nonzero;
                    PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter();
                    pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z");
                    ((Path)but.FindName(but.Name + "Path")).Data = pg;
                    isRepeat = true;
                }
                else
                {
                    isRepeat        = false;
                    but.MouseLeave += Button_MouseLeave;
                    ((Path)but.FindName(but.Name + "Path")).Fill = new SolidColorBrush(Color.FromRgb(98, 114, 123));
                }
            }
        }
示例#3
0
        static void OnDataStringPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var ctrl = bindable as FlexiblePath;
            var convertedGeometry = new PathGeometry();

            PathFigureCollectionConverter.ParseStringToPathFigureCollection(convertedGeometry.Figures, newValue.ToString());
            ctrl.Data = convertedGeometry;
        }
示例#4
0
        public override object ConvertFromInvariantString(string value)
        {
            PathGeometry pathGeometry = new PathGeometry();

            PathFigureCollectionConverter.FillFigures(pathGeometry.Figures, value, true);

            return(pathGeometry);
        }
示例#5
0
 private void Player_PlayStateChange(int NewState)
 {
     // MessageBox.Show(NewState.ToString());
     if (NewState == 3)
     {
         SongNameLabel.Content = String.Join(", ", Playlist[CurrentMediaIndex].Performers) + " - " + Playlist[CurrentMediaIndex].Title;
     }
     if (NewState == 8)
     {
         if (!Player.settings.getMode("loop"))
         {
             PathGeometry pg = new PathGeometry();
             pg.FillRule = FillRule.Nonzero;
             PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter();
             pg.Figures            = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z");
             ToggleButtonPath.Data = pg;
             ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg;
             Player.controls.stop();
             if (isRepeat)
             {
                 if (CurrentMediaIndex + 1 == Playlist.Count)
                 {
                     CurrentMediaIndex   = 0;
                     Player.currentMedia = Playlist[CurrentMediaIndex].Media;
                 }
                 else
                 {
                     CurrentMediaIndex++;
                     Player.currentMedia = Playlist[CurrentMediaIndex].Media;
                 }
             }
             else
             {
                 if (CurrentMediaIndex + 1 != Playlist.Count)
                 {
                     CurrentMediaIndex++;
                     Player.currentMedia = Playlist[CurrentMediaIndex].Media;
                 }
             }
             System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
             dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
             dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
             dispatcherTimer.Start();
         }
     }
 }
示例#6
0
        protected override void Init()
        {
            var layout      = new StackLayout();
            var statusLabel = new Label
            {
                AutomationId = StatusLabelId,
                Text         = ResetStatus,
            };

            var lgb = new LinearGradientBrush();

            lgb.GradientStops.Add(new GradientStop(Color.White, 0));
            lgb.GradientStops.Add(new GradientStop(Color.Orange, 1));

            var pathGeometry = new PathGeometry();

            PathFigureCollectionConverter.ParseStringToPathFigureCollection(pathGeometry.Figures, "M0,0 V300 H300 V-300 Z");

            var path = new Path
            {
                AutomationId = PathId,
                Data         = pathGeometry,
                Fill         = lgb
            };

            var touch = new TapGestureRecognizer
            {
                Command = new Command(_ => statusLabel.Text = ClickedStatus),
            };

            path.GestureRecognizers.Add(touch);

            var resetButton = new Button
            {
                Text    = "Reset",
                Command = new Command(_ => statusLabel.Text = ResetStatus),
            };

            layout.Children.Add(path);
            layout.Children.Add(statusLabel);
            layout.Children.Add(resetButton);

            Content = layout;
        }
示例#7
0
        /// <summary>
        /// using previously accumulated LidarData, draws the boundaries of the scanned area.
        /// </summary>
        private void drawScannedArea()
        {
            if (numRays >= 2)
            {
                StringBuilder psb = new StringBuilder();

                // the "Path" coordinates of the center of ray rotation:
                int centerX = (int)Math.Round(ScannedArea.ActualWidth / 2.0d);
                int centerY = (int)ScannedArea.ActualHeight;

                psb.AppendFormat("M{0},{1} ", centerX, centerY);

                foreach (int angleRaw in _lidarData.angles.Keys)
                {
                    RangeReading reading = _lidarData.getLatestReadingAt(angleRaw);

                    if (reading != null)
                    {
                        // 0 = full range,  centerY = zero range
                        double lineLength   = reading.rangeMeters * ScannedArea.ActualHeight / rangeMaxValueM;
                        double angleDegrees = reading.angleDegrees - (angleMaxValue - angleMinValue) / 2.0d;
                        double angleRads    = angleDegrees * Math.PI / 180.0d;

                        int x1 = (int)Math.Round(lineLength * Math.Sin(angleRads)) + centerX;
                        int y1 = -(int)Math.Round(lineLength * Math.Cos(angleRads)) + centerY;

                        // Tracer.Trace("angle: " + angleDegrees + "/" + angleRads + " x=" + x1 + " y=" + y1);

                        psb.AppendFormat("L{0},{1} ", x1, y1);
                    }
                }

                psb.Append("z");

                // Tracer.Trace(psb.ToString());

                PathFigureCollectionConverter fcvt    = new PathFigureCollectionConverter();
                PathFigureCollection          figures = (PathFigureCollection)fcvt.ConvertFromString(psb.ToString()); //"M200,200 L100,10 L100,10 L50,100 z");
                ScannedArea.Data = new PathGeometry(figures);

                drawReferenceCircles();
            }
        }
示例#8
0
        private void TrackPlayButton_Click(object sender, RoutedEventArgs e)
        {
            Button but = sender as Button; //("M8 5v14l11-7z"); M6 19h4V5H6v14zm8 - 14v14h4V5h - 4z

            if (CurrentMediaIndex == int.Parse(but.Name.Substring("PlayTrackButton".Length)))
            {
                PlayerToggle();
            }
            else
            {
                PathGeometry pg = new PathGeometry();
                pg.FillRule = FillRule.Nonzero;
                PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter();
                pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z");
                ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg;
                Player.controls.stop();
                CurrentMediaIndex   = int.Parse(but.Name.Substring("PlayTrackButton".Length));
                Player.currentMedia = Playlist[CurrentMediaIndex].Media;
                PlayerToggle();
            }
        }
示例#9
0
        private void PrevButton_Click(object sender, RoutedEventArgs e)
        {
            PathGeometry pg = new PathGeometry();

            pg.FillRule = FillRule.Nonzero;
            PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter();

            pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z");
            ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg;
            Player.controls.stop();
            if (CurrentMediaIndex == 0)
            {
                CurrentMediaIndex   = Playlist.Count - 1;
                Player.currentMedia = Playlist.Last().Media;
            }
            else
            {
                CurrentMediaIndex--;
                Player.currentMedia = Playlist[CurrentMediaIndex].Media;
            }
            PlayerToggle();
        }
示例#10
0
 private void PlayerToggle()
 {
     if (Player.playState != WMPPlayState.wmppsPlaying)
     {
         Player.controls.play();
         PathGeometry pg = new PathGeometry();
         pg.FillRule = FillRule.Nonzero;
         PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter();
         pg.Figures            = (PathFigureCollection)pfcc.ConvertFrom("M6 19h4V5H6v14zm8-14v14h4V5h-4z");
         ToggleButtonPath.Data = pg;
         ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg;
     }
     else
     {
         Player.controls.pause();
         PathGeometry pg = new PathGeometry();
         pg.FillRule = FillRule.Nonzero;
         PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter();
         pg.Figures            = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z");
         ToggleButtonPath.Data = pg;
         ((Path)FindName("PlayTrackButton" + CurrentMediaIndex.ToString() + "Path")).Data = pg;
     }
 }
示例#11
0
        private void PlaylistButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect      = true;
            ofd.DefaultExt       = ".mp3";
            ofd.Filter           = "Audio files (*.mp3)|*.mp3";
            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            if (ofd.ShowDialog() == true)
            {
                //Playlist.Clear();
                foreach (string filename in ofd.FileNames)
                {
                    var mp3File = TagLib.File.Create(filename);
                    Playlist.Add(new Track {
                        Media      = Player.newMedia(filename),
                        Title      = mp3File.Tag.Title,
                        Performers = mp3File.Tag.Performers,
                        Duration   = mp3File.Properties.Duration.ToString("mm\\:ss")
                    });
                    Console.WriteLine("Artist: " + String.Join(", ", mp3File.Tag.Performers));
                    Console.WriteLine("Track number: " + mp3File.Tag.Track);
                    Console.WriteLine("Title: " + mp3File.Tag.Title);
                    Console.WriteLine("Album: " + mp3File.Tag.Album);
                    Console.WriteLine("Year: " + mp3File.Tag.Year);
                    Console.WriteLine("Genre: " + mp3File.Tag.FirstGenre);
                    Console.WriteLine("Bitrate: " + mp3File.Properties.AudioBitrate + " kbps");
                    Console.WriteLine("Channels: " + mp3File.Properties.AudioChannels);
                    Console.WriteLine("Duration: " + mp3File.Properties.Duration.ToString("mm\\:ss"));
                    RowDefinition gridRow = new RowDefinition();
                    gridRow.Height = new GridLength(50);
                    Style st = FindResource("PlayerButton") as Style;
                    PlaylistGrid.RowDefinitions.Add(gridRow);
                    Button TrackPlayButton = new Button()
                    {
                        Name                = "PlayTrackButton" + (Playlist.Count - 1).ToString(),
                        Style               = st,
                        Foreground          = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                        Background          = Brushes.Transparent,
                        Height              = 40,
                        Width               = 40,
                        Cursor              = Cursors.Hand,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin              = new Thickness(10, 0, 10, 0),
                    };
                    TrackPlayButton.MouseEnter += TrackPlayButton_MouseEnter;
                    TrackPlayButton.MouseLeave += TrackPlayButton_MouseLeave;
                    TrackPlayButton.Click      += TrackPlayButton_Click;
                    PathGeometry pg = new PathGeometry();
                    pg.FillRule = FillRule.Nonzero;
                    PathFigureCollectionConverter pfcc = new PathFigureCollectionConverter();
                    pg.Figures = (PathFigureCollection)pfcc.ConvertFrom("M8 5v14l11-7z");
                    Path ButtonPath = new Path()
                    {
                        Name                = "PlayTrackButton" + (Playlist.Count - 1).ToString() + "Path",
                        Fill                = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                        Data                = pg,
                        Stretch             = Stretch.Fill,
                        Height              = 15,
                        Width               = 11,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center
                    };
                    Grid PathGrid = new Grid()
                    {
                        Width  = 10,
                        Height = 15,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center
                    };
                    Label TrackName = new Label()
                    {
                        Content           = String.Join(", ", mp3File.Tag.Performers) + " - " + mp3File.Tag.Title,
                        Foreground        = Brushes.White,
                        VerticalAlignment = VerticalAlignment.Center,
                        Margin            = new Thickness(60, 0, 0, 0),
                    };
                    PathGrid.Children.Add(ButtonPath);
                    TrackPlayButton.Content = PathGrid;
                    Border Container = new Border()
                    {
                        Height          = 50,
                        Background      = Brushes.Transparent,
                        BorderBrush     = new SolidColorBrush(Color.FromRgb(55, 70, 79)),
                        BorderThickness = new Thickness(0, 0, 0, 2),
                        Child           = TrackPlayButton
                    };

                    Grid.SetRow(Container, Playlist.Count - 1);
                    Grid.SetColumn(Container, 0);
                    Grid.SetRow(TrackName, Playlist.Count - 1);
                    Grid.SetColumn(TrackName, 0);
                    PlaylistGrid.Children.Add(Container);
                    PlaylistGrid.Children.Add(TrackName);
                    if (PlaylistGrid.FindName(ButtonPath.Name) == null)
                    {
                        PlaylistGrid.RegisterName(ButtonPath.Name, ButtonPath);
                    }
                    if (PlaylistScroll.Height < 250)
                    {
                        PlaylistScroll.Height += 50;
                    }
                }
            }
            Player.controls.stop();
            if (Playlist.Count > 0)
            {
                Player.currentMedia = Playlist[0].Media;
                CurrentMediaIndex   = 0;
                PlayerToggle();
            }
        }
示例#12
0
 public void SetUp()
 {
     _pathFigureCollectionConverter = new PathFigureCollectionConverter();
 }