private async Task <CodeFile> OnLoadBlock(CodeFile file) { if (!LoadedFiles.Contains(file.RelativeUrl)) { LoadedFiles.Add(file.RelativeUrl); try { var responseMessage = await httpClient.GetAsync($"{HostUrl}{Project}/{file.RelativeUrl}"); if (responseMessage.IsSuccessStatusCode) { file.Source = await responseMessage.Content.ReadAsStringAsync(); file.Data = await responseMessage.Content.ReadAsByteArrayAsync(); return(file); } else { if (file.FileName == "makefile") { await new SourceLoader(Project, HostUrl, OnFinishFile, LoadedFiles).StartAsync("main.cpp"); } } } catch (HttpRequestException) { if (file.FileName == "makefile") { await new SourceLoader(Project, HostUrl, OnFinishFile, LoadedFiles).StartAsync("main.cpp"); } } } return(null); }
public void ParseFiles(int gameAreaChangeCount) { if (AllFiles != null) { LoadedInThisArea = new Dictionary <string, FileInformation>(1024); foreach (var file in AllFiles) { if (file.Value.ChangeCount == gameAreaChangeCount) { LoadedInThisArea[file.Key] = file.Value; } if (file.Key[0] == 'M' && file.Key[8] == '/') { Metadata[file.Key] = file.Value; } else if (file.Key[0] == 'D' && file.Key[4] == '/' && file.Key.EndsWith(".dat")) { Data[file.Key] = file.Value; } else { OtherFiles[file.Key] = file.Value; } } LoadedFiles?.Invoke(this, LoadedInThisArea); } }
public void RemoveFiles(IEnumerable <LoadedFile> files) { foreach (LoadedFile f in files) { LoadedFiles.Remove(f); loadedPaths.Remove(f.Filename.ToLower()); } }
/// <summary> /// Parses the metadata of the given <paramref name="files"/>. /// </summary> /// <param name="files">Files whose metadata to parse.</param> /// <returns>Task.</returns> private async Task ParseFiles(string[] files) { OnStatusUpdated("Trying to parse selected files..."); List <string> errors = new List <string>(); var newFiles = new List <LoadedFileViewModel>(); await Task.Run(() => { foreach (string file in files) { try { if (SUPPORTEDFILES.Contains(Path.GetExtension(file).ToLower())) { ILocalFile audioFile = _localFileFactory.CreateFile(file); if (string.IsNullOrEmpty(audioFile.Artist)) { throw new Exception("No artist name found"); } if (string.IsNullOrEmpty(audioFile.Track)) { throw new Exception("No track name found"); } LoadedFileViewModel vm = new LoadedFileViewModel(audioFile); vm.ToScrobbleChanged += ToScrobbleChanged; newFiles.Add(vm); } } catch (Exception ex) { errors.Add(string.Format("{0} {1}", file, ex.Message)); } } }); LoadedFiles = new ObservableCollection <LoadedFileViewModel>(LoadedFiles.Concat(newFiles)); if (errors.Count > 0) { OnStatusUpdated(string.Format("Finished parsing selected files. {0} files could not be parsed", errors.Count)); if (_windowManager.MessageBoxService.ShowDialog("Some files could not be parsed. Do you want to save a text file with the files that could not be parsed?", "Error parsing files", IMessageBoxServiceButtons.YesNo) == IMessageBoxServiceResult.Yes) { IFileDialog sfd = _windowManager.CreateSaveFileDialog(); sfd.Filter = "Text Files|*.txt"; if (sfd.ShowDialog()) { _fileOperator.WriteAllLines(sfd.FileName, errors.ToArray()); } } } else { OnStatusUpdated("Successfully parsed selected files"); } }
internal static async void StatusCheck() { if (WaitGameStart) { if (!GetSelectedReceiveStatus()) { return; } WaitGameStart = false; AutoRG.CancelAsync(); MainWorker.MapFileWatcher.EnableRaisingEvents = false; await Task.Delay(500); CameraInit(); GameDelay = Settings.GameDelay; if (Settings.IsAutoLoad) { await Task.Delay(3000); LoadCodeSelect(); } } else { if (!WaitLobby && CurrentMusicState == MusicState.BattleNet) { GameDelay = 50; WaitLobby = true; Warcraft3Info.Refresh(); } if (!WaitLobby || GameDelay != 100) { return; } GameDelay = 550; if (Settings.IsCheatMapCheck && !LoadedFiles.IsLoadedMap(out _)) { MainWorker.MapFileWatcher.EnableRaisingEvents = true; } if (File.Exists($"{DocumentPath}\\Replay\\LastReplay.w3g")) { try { File.Delete($"{DocumentPath}\\Replay\\CirnixReplay.w3g"); File.Move($"{DocumentPath}\\Replay\\LastReplay.w3g", $"{DocumentPath}\\Replay\\CirnixReplay.w3g"); } catch { // Delete : CirnixReplay.w3g 경로에 대한 액세스가 거부되었습니다. // 백신때문으로 유추 } } WaitLobby = false; WaitGameStart = true; } }
/// <summary> /// Parses the metadata of the given <paramref name="files"/>. /// </summary> /// <param name="files">Files whose metadata to parse.</param> /// <returns>Task.</returns> private async Task ParseFiles(string[] files) { OnStatusUpdated("Trying to parse selected files..."); List <string> errors = new List <string>(); await Task.Run(() => { foreach (string file in files) { try { if (SUPPORTEDFILES.Contains(Path.GetExtension(file).ToLower())) { TagLib.File audioFile = TagLib.File.Create(file); if (audioFile.Tag.FirstPerformer == null || audioFile.Tag.Title == null) { throw new Exception("No artist name or track title found!"); } LoadedFileViewModel vm = new LoadedFileViewModel(audioFile); vm.ToScrobbleChanged += ToScrobbleChanged; _dispatcher.Invoke(() => LoadedFiles.Add(vm)); } } catch (Exception ex) { errors.Add(file + " " + ex.Message); } } }); if (errors.Count > 0) { OnStatusUpdated("Finished parsing selected files. " + errors.Count + " files could not be parsed"); if (MessageBox.Show("Some files could not be parsed. Do you want to save a text file with the files that could not be parsed?", "Error parsing files", MessageBoxButtons.YesNo) == DialogResult.Yes) { SaveFileDialog sfd = new SaveFileDialog() { Filter = "Text Files|*.txt" }; if (sfd.ShowDialog() == DialogResult.OK) { File.WriteAllLines(sfd.FileName, errors.ToArray()); } } } else { OnStatusUpdated("Successfully parsed selected files. Parsed " + LoadedFiles.Count + " files"); } }
/// <summary> /// Creates the list of the tracks that will be scrobbled. /// </summary> /// <returns>List with scrobbles.</returns> protected override IEnumerable <Scrobble> CreateScrobbles() { DateTime timePlayed = Time; List <Scrobble> scrobbles = new List <Scrobble>(); foreach (var vm in LoadedFiles.Where(i => i.ToScrobble).Reverse()) { scrobbles.Add(new Scrobble(vm.LoadedFile.Tag.FirstPerformer, vm.LoadedFile.Tag.Album, vm.LoadedFile.Tag.Title, timePlayed) { AlbumArtist = vm.LoadedFile.Tag.FirstAlbumArtist, Duration = vm.LoadedFile.Properties.Duration }); timePlayed = timePlayed.Subtract(vm.LoadedFile.Properties.Duration); } return(scrobbles); }
private void LoadAudio() { LoadedFiles.Add(FileLocation); var file = FileName.Split('.'); switch (file[1]) { case "mp3": file[1] = "mpegvideo"; break; case "wav": file[1] = "waveaudio"; break; } mciSendString($"open {FileLocation} type waveaudio alias {FileName}"); }
public void AddFiles(IEnumerable <string> paths, int index) { paths = Utils.ExpandDirectories(paths); foreach (string path in paths) { string lowerPath = path.ToLower(); if (!loadedPaths.Contains(lowerPath)) { try { LoadedFile f = new LoadedFile(path); LoadedFiles.Insert(index++, f); loadedPaths.Add(lowerPath); } catch (HaException) { } } } }
/// <summary> /// Imports a dictionary identified by an import directive. /// </summary> private void Import(ImportDirective directive) { // check if already loaded. if (LoadedFiles.ContainsKey(directive.Namespace)) { return; } TypeDictionary dictionary = (TypeDictionary)Load( typeof(TypeDictionary), directive.Namespace, directive.Location, Assembly.GetExecutingAssembly()); // verify namespace. if (!String.IsNullOrEmpty(dictionary.TargetNamespace) && directive.Namespace != dictionary.TargetNamespace) { throw Exception("Imported dictionary '{0}' does not match uri specified: '{1}'.", dictionary.TargetNamespace, directive.Namespace); } // save file. LoadedFiles.Add(dictionary.TargetNamespace, dictionary); // import nested dictionaries. if (dictionary.Import != null) { for (int ii = 0; ii < dictionary.Import.Length; ii++) { Import(dictionary.Import[ii]); } } // import types. if (dictionary.Items != null) { foreach (DataType datatype in dictionary.Items) { ImportDataType(datatype, dictionary.TargetNamespace); } } }
internal static void LoadCodeSelect() { string MapPath; if (!LoadedFiles.IsLoadedMap(out MapPath)) { SendMsg(true, "로드된 맵이 없습니다."); return; } MapPath = MapPath.Substring(MapPath.IndexOf(@"\Warcraft III\Maps\") + 14); if (MapPath.Contains("twrpg")) { Delay(3000); LoadCode2(); } else { LoadCode(); } }
public void ParseFiles(int gameAreaChangeCount) { if (AllFiles != null) { LoadedInThisArea = new Dictionary <string, FileInformation>(1024); foreach (var file in AllFiles) { if (file.Value.ChangeCount == gameAreaChangeCount) { LoadedInThisArea[file.Key] = file.Value; } if (file.Key[0] == 'M' && file.Key[8] == '/') { Metadata[file.Key] = file.Value; } else if (file.Key[0] == 'D' && file.Key[4] == '/' && file.Key.EndsWith(".dat")) { Data[file.Key] = file.Value; } else { OtherFiles[file.Key] = file.Value; } } /*Task.Run(() => * { * GroupedByTest2 = Files.GroupBy(x => x.Value.Test2).OrderBy(x=>x.Key).ToDictionary(z => z.Key, w => w.ToList()); * GroupedByChangeAction = Files.GroupBy(x => x.Value.ChangeCount ).OrderBy(x=>x.Key).ToDictionary(z => z.Key, w => w.ToList()); * }); */ LoadedFiles?.Invoke(this, LoadedInThisArea); } }
/// <summary> /// Imports a dictionary identified by an import directive. /// </summary> private async Task Import(ImportDirective directive) { // check if already loaded. if (LoadedFiles.ContainsKey(directive.Namespace)) { return; } TypeDictionary dictionary = (TypeDictionary)Load(typeof(TypeDictionary), directive.Namespace, directive.Location); // verify namespace. if (!String.IsNullOrEmpty(dictionary.TargetNamespace) && directive.Namespace != dictionary.TargetNamespace) { throw Exception("Imported dictionary '{0}' does not match uri specified: '{1}'.", dictionary.TargetNamespace, directive.Namespace); } // save file. LoadedFiles.Add(dictionary.TargetNamespace, dictionary); // import nested dictionaries. if (dictionary.Import != null) { for (int ii = 0; ii < dictionary.Import.Length; ii++) { await Import(dictionary.Import[ii]).ConfigureAwait(false); } } // import types. if (dictionary.Items != null) { foreach (TypeDescription description in dictionary.Items) { ImportDescription(description, dictionary.TargetNamespace); } } }
/// <summary> /// Removes the selected files. /// </summary> public void RemoveFiles() { LoadedFiles = new ObservableCollection <LoadedFileViewModel>(LoadedFiles.Where(i => !i.ToScrobble).ToList()); NotifyCanProperties(); }