public string GetFileName(EnumFileType type, string modelName) { string path = GetPath() + modelName + "//"; switch (type) { case EnumFileType.MatrixG: break; case EnumFileType.MatrixF: break; case EnumFileType.Lc: path = path + "Lc.Matrix."; break; case EnumFileType.B: path = path + "B.Matrix."; break; case EnumFileType.E: path = path + "E.Matrix."; break; case EnumFileType.G: path = path + "E.Matrix."; break; case EnumFileType.EigenMatrix: path = path + "matrix.Matrix."; break; } return path; }
public string GetFileName(EnumFileType type, string modelName) { string path = GetPath() + modelName + "//"; switch (type) { case EnumFileType.MatrixG: break; case EnumFileType.MatrixF: break; case EnumFileType.Lc: path = path + "Lc.Matrix."; break; case EnumFileType.B: path = path + "B.Matrix."; break; case EnumFileType.E: path = path + "E.Matrix."; break; case EnumFileType.G: path = path + "E.Matrix."; break; case EnumFileType.EigenMatrix: path = path + "matrix.Matrix."; break; } return(path); }
private static EnumFileType GetEnumFileType(IEnumerable <IFiletype> fts) { var items = fts.Select(GetEnumFileType); EnumFileType e = items.First(); items.Skip(1).ToList().ForEach(x => e |= x); return(e); }
public FileOperation(UndoRedoCmdType type, string old, List <string> s, string news = null, List <string> t = null, EnumFileType fileType = EnumFileType.TxtFile) { this.type = type; this.source = s; this.target = t; this.oldName = old; this.newName = news; this.fileType = fileType; }
} //kb public ShortFileInfo(string name, EnumFileType type, string modifiedtime, int size) { this.name = name; this.type = type; this.modifiedTime = modifiedtime; this.size = this.type == EnumFileType.TxtFile ? MyDiskManager.Instance().numOfBlock(size) + "kb" : ""; string uri = (type == EnumFileType.TxtFile ? "images/file.png" : "images/folder.png"); this.image = new BitmapImage(new Uri(uri, UriKind.Relative)); }
public string NewFile(string name, EnumFileType type) { name = getRightName(name); FileEntry node = newFileNode(name, type); diskManager.AllocFile(node); currentDir.InsertChild(node); undoList.Push(new FileOperation(UndoRedoCmdType.New, name, currentDir.getFilePath(), null, null, type)); notifyAll(); return(name); }
private void Sfd_FileOk(object sender, CancelEventArgs e) { var tag = saveFileDialog1.Tag as dynamic; var si = tag.si as SongItem; EnumFileType type = (EnumFileType)tag.ft; Task.Run(async() => { var stream = saveFileDialog1.OpenFile(); await api.downloadSongAsync(si, stream, type); stream.Dispose(); await api.downloadLyricAsync(si, new FileInfo(saveFileDialog1.FileName).Directory.FullName); MessageBox.Show("下载完成"); }); }
public static FileInfo Create(IFormFile file, string createdById, EnumFileType fileType, Guid?personId = null, Guid?organizationId = null, Guid?classId = null) { var result = new FileInfo() { CreatedById = createdById, PersonId = personId, ClassId = classId, OrganizationId = organizationId, Extention = file.ContentType, Name = file.FileName, RealName = Guid.NewGuid().ToString(), Data = file.GetBytes(), FileType = fileType }; return(result); }
private FileEntry newFileNode(string name, EnumFileType type) { FileEntry entry; FileEntry inner = new FileEntry( name, Utility.getCurrentTime(), Utility.getCurrentTime(), 0, 0, 0); if (type == EnumFileType.TxtFile) { entry = new File(inner); } else { entry = new Folder(inner); } return(entry); }
public static bool DownloadMusic_Inside(IntPtr Native_SongItemPtr, EnumFileType type, IntPtr dirPtr, int dirlength) { try { Native_SongItem nsi = Marshal.PtrToStructure <Native_SongItem>(Native_SongItemPtr); string dir = null; unsafe { dir = new string((char *)dirPtr.ToPointer(), 0, dirlength); } Console.WriteLine($"准备下载{nsi.name.RemoveUnicodeEnd()}到{dir}"); //转换 ISongItem si = SearchResultExtend.ToSongItem(nsi); var api = new QQMusicAPI(); api.downloadSongAsync(si, dir, type).Wait(); api.downloadLyricAsync(si, dir).Wait(); return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
/// <summary> /// 获取当前歌曲可用的格式并按大小降序排列 /// </summary> /// <returns></returns> public EnumFileType GetAvailableFileType() { EnumFileType tp = 0; List <IFiletype> list = new List <IFiletype>(5); if ((size_128 ?? 0) > 0) { tp |= EnumFileType.Mp3_128k; } if ((size_320 ?? 0) > 0) { tp |= EnumFileType.Mp3_320k; } if ((size_aac ?? 0) > 0) { // } if ((size_ogg ?? 0) > 0) { // } if ((size_dts ?? 0) > 0) { // } if ((size_ape ?? 0) > 0) { tp |= EnumFileType.Ape; } if ((size_flac ?? 0) > 0) { tp |= EnumFileType.Flac; } //System.Linq.Expresions.ExpressionCreator < System.Action < System.Object,System.Object >> return(tp); }
public bool DoesMatch(Stream stream, EnumFileType fileType) { return fileType.Equals(Detect(stream)); }
public static bool DownloadMusic(IntPtr Native_SongItemPtr, EnumFileType type, IntPtr dirPtr, int dirlength) { return(DownloadMusic_Inside(Native_SongItemPtr, type, dirPtr, dirlength)); }
public FilterByEnumFileTypeArgs(EnumFileType ft) { FileType = ft; }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (0 > e.RowIndex) { return; } Hzexe.QQMusic.Model.SongItem si = (dataGridView1.Rows[e.RowIndex].DataBoundItem as TableModel).SongItem; var col = dataGridView1.Columns[e.ColumnIndex]; Action <EnumFileType, SongItem> fun = new Action <EnumFileType, SongItem>((ext, obj) => { var att = ext.GetFileType(); string musicfilename = $"{obj.title}-{obj.singer[0].name}.{att.Suffix}"; saveFileDialog1.CheckPathExists = true; saveFileDialog1.CheckFileExists = false; saveFileDialog1.DefaultExt = att.Suffix; saveFileDialog1.OverwritePrompt = true; saveFileDialog1.ValidateNames = true; saveFileDialog1.Tag = new { si = obj, ft = ext }; saveFileDialog1.Filter = $"{att.Suffix}(*.{att.Suffix})|*.{att.Suffix}"; saveFileDialog1.FileName = musicfilename; saveFileDialog1.ShowDialog(); }); if ("Ape" == col.DataPropertyName) { fun(EnumFileType.Ape, si); } else if ("Flac" == col.DataPropertyName) { fun(EnumFileType.Flac, si); } else if ("Mp3_320k" == col.DataPropertyName) { fun(EnumFileType.Mp3_320k, si); } else if ("Mp3_128k" == col.DataPropertyName) { fun(EnumFileType.Mp3_128k, si); } else if ("M4a" == col.DataPropertyName) { fun(EnumFileType.M4a, si); } else if ("Play" == col.DataPropertyName) { EnumFileType type = si.file.GetAvailableFileType();//取当前歌曲可用的类型 EnumFileType downloadType = 0; downloadType |= (type & EnumFileType.Ape); if (downloadType == 0) { downloadType |= (type & EnumFileType.Flac); } if (downloadType == 0) { downloadType |= (type & EnumFileType.Mp3_320k); } if (downloadType == 0) { downloadType |= (type & EnumFileType.Mp3_128k); } if (downloadType == 0) { downloadType |= (type & EnumFileType.M4a); } string url = api.GetDownloadSongUrl(si, downloadType); mediaPlayer.SetMedia(new Uri(url)); Task.Run(async() => { //尝试载歌词 var ms = new System.IO.MemoryStream(); if (await api.downloadLyricAsync(si, ms)) { ms.Position = 0; lrc = Lrc.InitLrc(ms); } else { lrc = null; } ms.Dispose(); mediaPlayer.Play(); }); } }
public static FileTypeAttribute GetFileType(this EnumFileType em) { return(GetFileType <FileTypeAttribute, EnumFileType>(em)); }
static void Main(string[] args) { var api = new QQMusicAPI(); //初始化一个实例 string songName = null; while (string.IsNullOrEmpty(songName)) { songName = GetUserInput("\r\n请输入要搜索的歌名"); } var arg = new SearchArg() { Keywords = songName }; arg.PageSize = 30; var result = api.SearchAsync(arg).Result; //搜索搜索并获取结果 if (result.song.list.Count > 0) { Console.WriteLine($"共搜索到{result.song.list.Count}个结果"); //为了简化示例,就取列表的第一条歌曲 var song = result.song.list[0]; EnumFileType type = song.file.GetAvailableFileType();//取当前歌曲可用的类型 Console.WriteLine(type); //获取当前目录用来存放音乐 string dir = AppContext.BaseDirectory; //要下载哪种类型的音乐呢? EnumFileType downloadType = 0; downloadType |= (type & EnumFileType.Ape); if (downloadType == 0) { downloadType |= (type & EnumFileType.Flac); } if (downloadType == 0) { downloadType |= (type & EnumFileType.Mp3_320k); } if (downloadType == 0) { downloadType |= (type & EnumFileType.Mp3_128k); } if (downloadType == 0) { downloadType |= (type & EnumFileType.M4a); } var t = api.downloadSongAsync(song, dir, downloadType);//建立下载的task,下载文件最大并保存到当前目录 //可选:当然也可以尝试lrc的歌词下载下来 var t2 = api.downloadLyricAsync(song, dir); Console.WriteLine("Start download:"); while (!t.IsCompleted) { Console.Write("."); System.Threading.Thread.Sleep(500); } t2.Wait(); Console.WriteLine(); if (t.IsFaulted) { Console.WriteLine($"Error:{t.Exception.Message}"); } else { Console.WriteLine("Download success!"); } } else { Console.WriteLine("没找到你需要的歌曲"); } Console.WriteLine("按任意键退出本示例"); Console.ReadKey(); }
public bool MatchType(Stream stream, string fileName, EnumFileType fileType) { return fileType.Equals(getFileType(stream, fileName)); }