private void PanoramaChanged(SelectionChangedEventArgs args) { var header = ((PanoramaItem)args.AddedItems[0]).Header.ToString(); switch (header) { case "Tracks": if (!Tracks.Any()) { LoadTracks(); } break; case "Palestrantes": if (!Palestrantes.Any()) { LoadPalestrantes(); } break; case "Palestras": if (!Palestras.Any()) { LoadPalestras(); } break; } }
private bool DoestTheTweetMatchAllConditions(ITweet tweet, string[] matchingTracks, ILocation[] matchingLocations, long[] matchingFollowers) { if (tweet == null || tweet.CreatedBy.Id == TweetinviSettings.DEFAULT_ID) { return(false); } bool followMatches = FollowingUserIds.IsEmpty() || matchingFollowers.Any(); bool tracksMatches = Tracks.IsEmpty() || matchingTracks.Any(); bool locationMatches = Locations.IsEmpty() || matchingLocations.Any(); if (FollowingUserIds.Any()) { return(followMatches && tracksMatches && locationMatches); } if (Tracks.Any()) { return(tracksMatches && locationMatches); } if (Locations.Any()) { return(locationMatches); } return(true); }
public string ToString(PlaylistType playlistType) { if (Type == PlaylistType.UNKNOW) { return(String.Empty); } if (!Tracks.Any()) { throw new Exception("No tracks found."); } if (playlistType != PlaylistType.XPSF && playlistType != PlaylistType.M3U) { throw new NotImplementedException("Format not implemented yet."); } var playlist = playlistType == PlaylistType.XPSF ? (IPlaylist) new XpsfPlaylist(Tracks) : (IPlaylist) new M3UPlaylist(Tracks); return(playlist.ToString()); //return RawData; }
private bool DoestTheTweetMatchAllConditions(ITweet tweet, IEnumerable <string> matchingTracks, IEnumerable <ILocation> matchingLocations) { if (tweet.CreatedBy.Id == TweetinviSettings.DEFAULT_ID) { return(false); } bool followMatches = FollowingUserIds.IsEmpty() || ContainsFollow(tweet.CreatedBy.Id); bool tracksMatches = Tracks.IsEmpty() || matchingTracks.Any(); bool locationMatches = Locations.IsEmpty() || matchingLocations.Any(); if (FollowingUserIds.Any()) { return(followMatches && tracksMatches && locationMatches); } if (Tracks.Any()) { return(tracksMatches && locationMatches); } if (Locations.Any()) { return(locationMatches); } return(true); }
private void CommitNameEdit(string oldName, string newName) { var duplicate = Tracks.Any(t => t != editingButton.Tag && t.Name == newName); if (duplicate) { MessageBox.Show(T._("Ein Gleis mit der Bezeichnung {0} ist bereits vorhanden. Bitte wählen Sie einen anderen Namen!", newName), MessageBoxType.Error); return; } // Streckengleise umbenennen DefaultTrackLeft.ReplaceAllValues(editingButton.Tag.Name, newName); DefaultTrackRight.ReplaceAllValues(editingButton.Tag.Name, newName); // Ankunfts- und Abfahrtsgleise zum umbenennen stagen if (TrackRenames.ContainsKey(newName)) { TrackRenames.Remove(newName); } else if (TrackRenames.ContainsValue(oldName)) { var k = TrackRenames.First(kvp => kvp.Value == oldName).Key; TrackRenames[k] = newName; } else if (!TrackRenames.ContainsKey(oldName) && !TrackRenames.ContainsValue(newName)) { TrackRenames.Add(oldName, newName); } editingButton.Tag.Name = newName; Invalidate(); editingButton = null; }
private void OnPreviewResults(bool showMessageIfNoResults) { Tracks = _trackSearchService.GetTracks(CreatePlaylist(_playlist)); if (showMessageIfNoResults && !Tracks.Any()) { _messenger.Send(new ShowDialogMessage(_messenger, MessageType.Info, "Criteria Playlist", "No tracks meet the selected criteria")); } }
public Track GetRandomTrack() { if (!Tracks.Any()) { return(null); } Random r = new Random(); return(Tracks.ToArray()[r.Next(Tracks.Count)]); }
private async void InspectFolders(IEnumerable <string> selectedFolders) { Value = 1; IsInsp = true; Max = selectedFolders.Select(o => Directory.GetFiles(o, "*.mp3", SearchOption.TopDirectoryOnly).Count()).Sum(); await Task.Run(() => { var date = DateTime.Now; System.Diagnostics.Debug.WriteLine("start"); if (!selectedFolders?.Any() ?? false) { return; } List <TrackViewModel> tracks = new List <TrackViewModel>(); foreach (var item in selectedFolders) { if (!OpenedFolders.Contains(item)) { OpenedFolders.Add(item); } var files = Directory.GetFiles(item, "*.mp3"); foreach (var file in files.Where(o => o.Split('.').LastOrDefault() == "mp3")) { if (Tracks.Any(o => string.Compare(o.Path, file, StringComparison.OrdinalIgnoreCase) == 0)) { continue; } try { App.Current.Dispatcher.Invoke(() => { Value++; }); tracks.Add(new TrackViewModel(file, item, _counterForID++)); } catch (Exception e) { MessageBox.Show(e.Message); } } } App.Current.Dispatcher.Invoke(() => { foreach (var item in tracks) { Tracks.Add(item); } IsInsp = false; }); System.Diagnostics.Debug.WriteLine("end " + (DateTime.Now - date)); }); }
public void HandleNegativeTracks() { // Handle negative offsets if (Tracks.Any(x => x.TrackPosition < 0)) { var ordTracks = Tracks.OrderBy(x => x.TrackPosition).ToList(); var lowest = ordTracks.First().TrackPosition * -1; foreach (var t in Tracks) { t.TrackPosition += lowest; } } }
public void UpdatePlaylist(ChromeDriver chromeDriver, Playlist playlist) { int count = 1; foreach (var music in playlist.Music) { //for (int i = 0; i < 45; i++) //{ //var music = playlist.Music[i]; string track; if (count < 10) { track = BaseService.RemoveInvalidPathChars("0" + count + " " + music.Artist + " - " + music.Name + ".mp3"); } else { track = BaseService.RemoveInvalidPathChars(count + " " + music.Artist + " - " + music.Name + ".mp3"); } //Get file by number DirectoryInfo pathDir = new DirectoryInfo(playlist.PathFolder); FileInfo[] Tracks; if (count < 10) { Tracks = pathDir.GetFiles("" + "0" + +count + "*.mp3"); } else { Tracks = pathDir.GetFiles("" + +count + "*.mp3"); } if (Tracks.Any()) { if (Tracks.FirstOrDefault().Name != track) { File.Delete(playlist.PathFolder + "\\" + Tracks[0].Name); music.NameAfterDownload = BaseService.Download(chromeDriver, playlist.PathFolder, music, count); } } else { music.NameAfterDownload = BaseService.Download(chromeDriver, playlist.PathFolder, music, count); } count++; } BaseService.WaitToDownload(playlist.PathFolder); BaseService.RenameFiles(playlist); }
private async Task <IEnumerable <LastTrack> > LoadTracks() { if (Tracks.Any()) { return(new List <LastTrack>()); } var response = await _lfClient.Artist.GetTopTracksAsync(Artist.Name, true); if (response.Success) { return(response); } else { throw new Exception(); } }
private async Task <IEnumerable <Audio> > LoadMoreAudios(uint page) { var response = await _inTouchWrapper.ExecuteRequest(_inTouch.Audio.Get( Album.OwnerId, (int)Album.Id, count: 50, offset: _offset)); if (response.IsError) { throw new Exception(response.Error.ToString()); } if (!Tracks.Any() && response.Data.Items.Any()) { SetDefaultMode(); } _offset += 50; return(response.Data.Items); }
public Uri GetNextTrack() { if (!Tracks.Any()) { return(null); } if (Repeat == RepeatMode.Song && CurrentTrack != null) { return(CurrentTrack.Uri); } if (Repeat == RepeatMode.None && CurrentTrack == Tracks.Last() && Shuffle == false) { return(null); } if (Repeat == RepeatMode.List && CurrentTrack == Tracks.Last() && Shuffle == false) { return(Tracks.First().Uri); } if ((Repeat == RepeatMode.List || Repeat == RepeatMode.None) && Shuffle == true) { return(GetRandomTrack().Uri); } if (CurrentTrack == null) { return(Tracks.First().Uri); } if (CurrentTrack != Tracks.Last()) { return(Tracks[Tracks.IndexOf(CurrentTrack) + 1].Uri); } return(null); }
public string DeriveTrackLabel(string baseLabel) { string separator = " "; int n; int padWidth; if (baseLabel == Track.DEFAULT_BASE_LABEL) { n = Tracks.Count + 1; padWidth = 2; } else { Match m = Regex.Match(baseLabel, @"(.+?)( ?)(\d+)$"); if (m.Success) { baseLabel = m.Groups[1].Value; separator = m.Groups[2].Value; n = int.Parse(m.Groups[3].Value) + 1; padWidth = m.Groups[3].Length; } else { n = 2; padWidth = 2; } } string label; do { label = baseLabel + separator + (n++).ToString().PadLeft(padWidth, '0'); }while (Tracks.Any(g => g.Label.Equals(label, StringComparison.InvariantCultureIgnoreCase))); return(label); }
private void AddBtn_Click(object sender, EventArgs e) { var regex = new Regex(@"^Gleis (\d+)$", RegexOptions.Compiled); var maxTrack = 0; var matchedTracks = Tracks.Select(t => regex.Match(t.Name)).Where(m => m.Success).ToArray(); if (matchedTracks.Any()) { maxTrack = matchedTracks.Select(m => int.Parse(m.Groups[1].Value)).Max(); } var track = new Track(tt) { Name = "Gleis " + (maxTrack + 1) }; if (!Tracks.Any()) { DefaultTrackLeft.SetValue(routeIndex, track.Name); DefaultTrackRight.SetValue(routeIndex, track.Name); } Tracks.Add(track); Invalidate(); }
public void DecodeTransData(object sender, RawTransponderDataEventArgs e) { OldTracks = new List <ITrack>(Tracks); Tracks.Clear(); foreach (var transData in e.TransponderData) { string[] trackData = transData.Split(';'); Track.Tag = trackData[0]; Track.X = int.Parse(trackData[1]); Track.Y = int.Parse(trackData[2]); Track.Altitude = int.Parse(trackData[3]); Track.TimeStamp = Convert.ToDateTime(MakeDateTimeString(trackData[4])); Track.Velocity = 0; Track.Course = 0; if (IsInAirspace(Track)) { // If same track is registered from next TransponderReceiver data, Course and Velocity are calculated if (OldTracks.Any(x => x.Tag == Track.Tag)) { ITrack oldTrack = OldTracks.FirstOrDefault(x => x.Tag == Track.Tag); Track.CalculateCourse(oldTrack, Track); Track.CalculateVelocity(oldTrack, Track); } ITrack insertTrack = new Track() { Altitude = Track.Altitude, Course = Track.Course, Tag = Track.Tag, TimeStamp = Track.TimeStamp, Velocity = Track.Velocity, X = Track.X, Y = Track.Y }; // Insert track in newest list of tracks Tracks.Add(insertTrack); } } foreach (var track in Tracks) { if (!OldTracks.Any(x => x.Tag == track.Tag)) { TrackEntered?.Invoke(track); Writer.Write("Track entered airspace! Time: " + DateTime.Now.ToShortTimeString() + " Tag: " + track.Tag); } } foreach (var track in OldTracks) { if (!Tracks.Any(x => x.Tag == track.Tag)) { TrackLeaving?.Invoke(track); Writer.Write("Track leaving airspace! Time: " + DateTime.Now.ToShortTimeString() + " Tag: " + track.Tag); } } //PrintToConsole(Tracks); // Print to GUI OnTracksReady?.Invoke(Tracks); // Check if any two tracks are colliding form list of tracks CollisionDetector.DetectCollision(Tracks); }
protected override void OnPaint(PaintEventArgs e) { // Reset e.Graphics.Clear(bgColor); buttons.Clear(); int midx = Width / 2; // Richtungsangaben ermitteln var route = tt.GetRoute(routeIndex).Stations; var staIdx = route.IndexOf(station); var prev = route.ElementAtOrDefault(staIdx - 1); var next = route.ElementAtOrDefault(staIdx + 1); bool disableRight = tt.Type == TimetableType.Network && next == null; bool disableLeft = tt.Type == TimetableType.Network && prev == null; // Richtungsangaben zeichnen if (prev != null) { e.Graphics.DrawText(font, textColor, 5, 5, T._("von {0}", prev.SName)); } if (next != null) { var nextText = T._("nach {0}", next.SName); var nextSize = e.Graphics.MeasureString(font, nextText); e.Graphics.DrawText(font, textColor, Width - 5 - nextSize.Width, 5, nextText); } var leftdefaultTrack = Tracks.IndexOf(Tracks.FirstOrDefault(t => t.Name == DefaultTrackLeft.GetValue(routeIndex))); var rightdefaultTrack = Tracks.IndexOf(Tracks.FirstOrDefault(t => t.Name == DefaultTrackRight.GetValue(routeIndex))); // Netzwerk: Falls noch keine Angabe: Standardgleise setzen if (tt.Type == TimetableType.Network && Tracks.Any()) { if (disableLeft) { leftdefaultTrack = 0; } else if (leftdefaultTrack == -1) { MoveDefaultTrack(DefaultTrackLeft, Tracks.First(), 0); leftdefaultTrack = 0; } if (disableRight) { rightdefaultTrack = 0; } else if (rightdefaultTrack == -1) { MoveDefaultTrack(DefaultTrackRight, Tracks.First(), 0); rightdefaultTrack = 0; } } int y = 30; int maxIndent = 0; foreach (var track in Tracks) { var trackIndex = Tracks.IndexOf(track); // Einrückung des Gleisvorfeldes berehcnen var leftIndent = Math.Abs(leftdefaultTrack - trackIndex) * INDENT + 60; if (leftdefaultTrack == trackIndex) { leftIndent = disableLeft ? 30 : 0; } var rightIndent = Math.Abs(rightdefaultTrack - trackIndex) * INDENT + 60; if (rightdefaultTrack == trackIndex) { rightIndent = disableRight ? 30 : 0; } maxIndent = Math.Max(maxIndent, rightIndent + leftIndent); rightIndent = Width - rightIndent; // Gleiselinie zeichnen e.Graphics.DrawLine(textColor, leftIndent, y, rightIndent, y); // Gleisverbindungen zeichnen if (trackIndex < leftdefaultTrack) { e.Graphics.DrawLine(textColor, leftIndent, y, leftIndent - INDENT, y + LINE_HEIGHT); } else if (trackIndex > leftdefaultTrack) { e.Graphics.DrawLine(textColor, leftIndent, y, leftIndent - INDENT, y - LINE_HEIGHT); } if (trackIndex < rightdefaultTrack) { e.Graphics.DrawLine(textColor, rightIndent, y, rightIndent + INDENT, y + LINE_HEIGHT); } else if (trackIndex > rightdefaultTrack) { e.Graphics.DrawLine(textColor, rightIndent, y, rightIndent + INDENT, y - LINE_HEIGHT); } // Gleisnamen als Button hinzufügen var textSize = e.Graphics.MeasureString(font, track.Name); var nameBtn = new RenderBtn <Track>(track, new Point(midx - (int)(textSize.Width / 2) - 5, y - 8), new Size((int)textSize.Width + 5, 16), bgColor, track.Name, textColor); nameBtn.Click += NameBtn_Click; buttons.Add(nameBtn); // Netzwerk: Standardgleise anderer Routen gestrichelt zeichnen. if (DefaultTrackLeft.ContainsValue(track.Name) && leftdefaultTrack != trackIndex) { e.Graphics.DrawLine(dashedPen, 0, y, leftIndent, y); } if (DefaultTrackRight.ContainsValue(track.Name) && rightdefaultTrack != trackIndex) { e.Graphics.DrawLine(dashedPen, rightIndent, y, Width, y); } // Aktions-Buttons hinzufügen var btnLeft = midx + (int)(textSize.Width / 2) + 10; var deleteBtn = GetButton("X", track, btnLeft, y); deleteBtn.Click += DeleteBtn_Click; var upBtn = GetButton("▲", track, btnLeft + 20, y); upBtn.Click += UpBtn_Click; var downBtn = GetButton("▼", track, btnLeft + 40, y); downBtn.Click += DownBtn_Click; // Aktionsbuttons für Standardgleise if (trackIndex == leftdefaultTrack && !disableLeft) { var leftUpBtn = GetButton("▲", track, 10, y); leftUpBtn.Click += (s, x) => MoveDefaultTrack(DefaultTrackLeft, ((RenderBtn <Track>)s).Tag, -1); var leftDownBtn = GetButton("▼", track, 30, y); leftDownBtn.Click += (s, x) => MoveDefaultTrack(DefaultTrackLeft, ((RenderBtn <Track>)s).Tag, 1); } if (trackIndex == rightdefaultTrack && !disableRight) { var rightUpButton = GetButton("▲", track, Width - 46, y); rightUpButton.Click += (s, x) => MoveDefaultTrack(DefaultTrackRight, ((RenderBtn <Track>)s).Tag, -1); var rightDownBtn = GetButton("▼", track, Width - 26, y); rightDownBtn.Click += (s, x) => MoveDefaultTrack(DefaultTrackRight, ((RenderBtn <Track>)s).Tag, 1); } y += LINE_HEIGHT; } // Button für neue Gleise var addTrackText = T._("Neues Gleis hinzufügen"); var textWidth = (int)e.Graphics.MeasureString(font, addTrackText).Width; var addBtn = new RenderBtn <Track>(null, new Point(midx - (textWidth / 2) - 5, y - 8), new Size(textWidth + 10, 16), Colors.LightGrey, addTrackText); buttons.Add(addBtn); addBtn.Click += AddBtn_Click; var newHeight = (Tracks.Count) * LINE_HEIGHT + 50; if (newHeight > Height) { this.Height = newHeight; } else if (maxIndent > Width - 30) { Width = maxIndent + 30; } foreach (var args in buttons) { args.Draw(e.Graphics); } base.OnPaint(e); }
public bool HasTrack(string number) => Tracks.Any(t => t.Number == number);
/// <summary> Checks the possibility to use buffer duration.</summary> /// <returns> If there is any task which could be fit into a buffer duration of a track.</returns> private bool CheckPossibilityToUseBufferDuration() { return(Tracks.Any(track => UnscheduledTalks.Any(talk => talk.Duration <= track.BufferDuration))); }
bool IPlaylist.ContainsPlayableTracks() { return(Tracks.Count > 0 && Tracks.Any(x => x.IsAvailable)); }