private void __sLibAdd_Click(object sender, EventArgs e) { if (__ofd.ShowDialog(this) != DialogResult.OK) { return; } var filename = __ofd.FileName; if (!System.IO.File.Exists(filename)) { return; } if (__sLib.Items.Contains(filename)) { return; } if (Miscellaneous.IsAssembly(filename)) { var ent = new LibraryEntry(filename); __sLib.Items.Add(ent); } else { MessageBox.Show(this, "The specified file is not a Managed Assembly", "Anolis Resourcer", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void PlaylistForm_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { if (File.Exists(file)) { SongInfo song = this.Library.GetSong(file); if (song == null) { song = new LibraryEntry(file); } this.Player.Playlist.AddToEnd(song); } else if (Directory.Exists(file)) { string[] files2 = Directory.GetFiles(file, "*", SearchOption.AllDirectories); foreach (string file2 in files2) { if (Array.IndexOf(this.Player.SupportedExtensions, "*" + Path.GetExtension(file2)) != -1) { SongInfo song = this.Library.GetSong(file2); if (song == null) { song = new LibraryEntry(file2); } this.Player.Playlist.AddToEnd(song); } } } } }
private void LoadSettings() { ////////////////////////////// // Toolbar Size __sUIButtonsLarge.Checked = !S.Toolbar24; ////////////////////////////// // Gimmicks __sGimmick.Checked = S.Gimmicks; ////////////////////////////// // File Associations var isAssoc = S.IsAssociatedWithFiles; __sAssoc.CheckState = isAssoc == TriState.True ? CheckState.Checked : isAssoc == TriState.False ? CheckState.Unchecked : CheckState.Indeterminate; __sAssoc.Enabled = Miscellaneous.IsElevatedAdministrator; ////////////////////////////// // Load Assemblies if (S.LoadAssemblies != null) { foreach (var filename in S.LoadAssemblies) { var ent = new LibraryEntry(filename); __sLib.Items.Add(ent); } } }
private void lbWeather_SelectedIndexChanged(object sender, EventArgs e) { int ndx = 0; string lineBreaker = Environment.NewLine + "--------------------------------------------" + Environment.NewLine; LibraryEntry lidEntry = InformationLibrary.WeatherEntries.Find(entry => entry.Name == lbWeather.SelectedItem.ToString()); string temp = lidEntry.Name + lineBreaker + lidEntry.Description; TbInformation.Text = string.Empty; TbInformation.Text = temp; string search = tbWeatherSearchKeyword.Text; while (ndx < TbInformation.TextLength) { int wordStartIndex = TbInformation.Find(search, ndx, RichTextBoxFinds.None); if (wordStartIndex != -1) { TbInformation.SelectionStart = wordStartIndex; TbInformation.SelectionLength = search.Length; TbInformation.SelectionBackColor = Color.Orange; } else { break; } ndx += wordStartIndex + search.Length; } }
public ActionResult AddToLibrary(string userId, int bookId, string value) { BookStatus status = BookStatus.ToRead; switch (value) { case "To read": status = BookStatus.ToRead; break; case "Reading": status = BookStatus.Reading; break; case "Read": status = BookStatus.Read; break; } ApplicationUser user = userManager.FindById(userId); Book book = db.Books.Where(x => x.BookId == bookId).FirstOrDefault(); LibraryEntry entry = db.LibraryEntries.Where(x => x.Book.BookId == bookId && x.User.Id == userId).FirstOrDefault(); if (entry == null) { db.LibraryEntries.Add(new LibraryEntry(user, book, status)); } else { entry.BookStatus = status; db.Entry(entry).State = EntityState.Modified; } db.SaveChanges(); return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public PlaybackHistoryEntry( LibraryEntry libraryEntry, DateTime playbackEndedDateTime) { this.LibraryEntry = libraryEntry ?? throw new ArgumentNullException(nameof(libraryEntry)); this.PlaybackEndedDateTime = playbackEndedDateTime; }
private void mnuReadTrackInformation_Click(object sender, EventArgs e) { songListView.SelectedItems.ForEach(delegate(SongListViewItem item) { var entry = new LibraryEntry(item.SongInfo.FileName); this.Library.Update(entry); }); }
private void btnOK_Click(object sender, EventArgs e) { // Update the library entries for (int i = 0; i < _libraryEntries.Length; i++) { string fileName = _libraryEntries[i].FileName; string title = _libraryEntries[i].Title; string album = _libraryEntries[i].Album; string artist = _libraryEntries[i].Artist; int trackNumber = _libraryEntries[i].TrackNumber; int year = _libraryEntries[i].Year; string genre = _libraryEntries[i].Genre; string albumArtist = _libraryEntries[i].AlbumArtist; if (txtTitle.Text.Length > 0) { title = txtTitle.Text; } if (txtAlbum.Text.Length > 0) { album = txtAlbum.Text; } if (txtArtist.Text.Length > 0) { artist = txtArtist.Text; } if (nudTrackNumber.Value > 0) { trackNumber = Convert.ToInt32(nudTrackNumber.Value); } if (nudYear.Value > 0) { year = Convert.ToInt32(nudYear.Value); } if (cboGenre.Text.Length > 0) { genre = cboGenre.Text; } if (txtAlbumArtist.Text.Length > 0) { albumArtist = txtAlbumArtist.Text; } var newSong = new LibraryEntry(fileName, artist, album, title, trackNumber, year, genre, albumArtist); this.Library.Update(newSong); } this.Close(); }
private void mnuEditTrackInformation_Click(object sender, EventArgs e) { if (songListView.SelectedItems.Count > 0) { var songs = new LibraryEntry[songListView.SelectedItems.Count]; for (int i = 0; i < songListView.SelectedItems.Count; i++) { songs[i] = songListView.SelectedItems[i].SongInfo as LibraryEntry; } var f = new InfoEditForm(songs); f.Library = this.Library; f.Player = this.Player; f.Show(this); } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { LibraryEntry book = values[0] as LibraryEntry; if (book == null) { return(false); } var library = values[1] as IEnumerable <LibraryEntry>; if ((string)parameter == "local") { return(library.Any(x => x.IsLocal && x.Id == book.Id)); } else { return(library.Any(x => x.IsRemote && x.Id == book.Id)); } }
private void CreateOrAddItem(List <SongListViewItem> itemsToAdd, string file) { SongListViewItem myOld = FindItem(file); if (myOld == null) { var item = new SongListViewItem(list); SongInfo song = this.Library.GetSong(file); if (song == null) { song = new LibraryEntry(file); } item.SongInfo = song; item.AlbumDisplay = item.SongInfo.Album; itemsToAdd.Add(item); } else { list.Items.Remove(myOld); itemsToAdd.Add(myOld); } }
/// <summary> /// Refreshes the contents of the content area. Must be called at least once after construction. /// </summary> /// <param name="viewType">Determines how to display the resource tiles.</param> /// <param name="entriesToDisplay">Project library entries to display.</param> /// <param name="bounds">Bounds within which to lay out the content entries.</param> public void Refresh(ProjectViewType viewType, LibraryEntry[] entriesToDisplay, Rect2I bounds) { if (mainPanel != null) mainPanel.Destroy(); entries.Clear(); entryLookup.Clear(); mainPanel = parent.Layout.AddPanel(); GUIPanel contentPanel = mainPanel.AddPanel(1); overlay = mainPanel.AddPanel(0); underlay = mainPanel.AddPanel(2); deepUnderlay = mainPanel.AddPanel(3); renameOverlay = mainPanel.AddPanel(-1); main = contentPanel.AddLayoutY(); List<ResourceToDisplay> resourcesToDisplay = new List<ResourceToDisplay>(); foreach (var entry in entriesToDisplay) { if (entry.Type == LibraryEntryType.Directory) resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single)); else { FileEntry fileEntry = (FileEntry)entry; ResourceMeta[] metas = fileEntry.ResourceMetas; if (metas.Length > 0) { if (metas.Length == 1) resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single)); else { resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.MultiFirst)); for (int i = 1; i < metas.Length - 1; i++) { string path = Path.Combine(entry.Path, metas[i].SubresourceName); resourcesToDisplay.Add(new ResourceToDisplay(path, LibraryGUIEntryType.MultiElement)); } string lastPath = Path.Combine(entry.Path, metas[metas.Length - 1].SubresourceName); resourcesToDisplay.Add(new ResourceToDisplay(lastPath, LibraryGUIEntryType.MultiLast)); } } } } if (viewType == ProjectViewType.List16) { tileSize = 16; gridLayout = false; elementsPerRow = 1; horzElementSpacing = 0; int elemWidth = bounds.width; int elemHeight = tileSize; main.AddSpace(TOP_MARGIN); for (int i = 0; i < resourcesToDisplay.Count; i++) { ResourceToDisplay entry = resourcesToDisplay[i]; LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entry.path, i, elemWidth, elemHeight, entry.type); entries.Add(guiEntry); entryLookup[guiEntry.path] = guiEntry; if (i != resourcesToDisplay.Count - 1) main.AddSpace(LIST_ENTRY_SPACING); } main.AddFlexibleSpace(); } else { int elemWidth = 0; int elemHeight = 0; int vertElemSpacing = 0; switch (viewType) { case ProjectViewType.Grid64: tileSize = 64; elemWidth = tileSize; elemHeight = tileSize + 36; horzElementSpacing = 10; vertElemSpacing = 12; break; case ProjectViewType.Grid48: tileSize = 48; elemWidth = tileSize; elemHeight = tileSize + 36; horzElementSpacing = 8; vertElemSpacing = 10; break; case ProjectViewType.Grid32: tileSize = 32; elemWidth = tileSize + 16; elemHeight = tileSize + 48; horzElementSpacing = 6; vertElemSpacing = 10; break; } gridLayout = true; int availableWidth = bounds.width; elementsPerRow = MathEx.FloorToInt((availableWidth - horzElementSpacing) / (float)(elemWidth + horzElementSpacing)); elementsPerRow = Math.Max(elementsPerRow, 1); int numRows = MathEx.CeilToInt(resourcesToDisplay.Count / (float)elementsPerRow); int neededHeight = numRows * elemHeight + TOP_MARGIN; if (numRows > 0) neededHeight += (numRows - 1)* vertElemSpacing; bool requiresScrollbar = neededHeight > bounds.height; if (requiresScrollbar) { availableWidth -= parent.ScrollBarWidth; elementsPerRow = MathEx.FloorToInt((availableWidth - horzElementSpacing) / (float)(elemWidth + horzElementSpacing)); elementsPerRow = Math.Max(elementsPerRow, 1); } int extraRowSpace = availableWidth - (elementsPerRow * (elemWidth + horzElementSpacing) + horzElementSpacing); main.AddSpace(TOP_MARGIN); GUILayoutX rowLayout = main.AddLayoutX(); rowLayout.AddSpace(horzElementSpacing); int elemsInRow = 0; for (int i = 0; i < resourcesToDisplay.Count; i++) { if (elemsInRow == elementsPerRow && elemsInRow > 0) { main.AddSpace(vertElemSpacing); rowLayout.AddSpace(extraRowSpace); rowLayout = main.AddLayoutX(); rowLayout.AddSpace(horzElementSpacing); elemsInRow = 0; } ResourceToDisplay entry = resourcesToDisplay[i]; LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, rowLayout, entry.path, i, elemWidth, elemHeight, entry.type); entries.Add(guiEntry); entryLookup[guiEntry.path] = guiEntry; rowLayout.AddSpace(horzElementSpacing); elemsInRow++; } int extraElements = elementsPerRow - elemsInRow; rowLayout.AddSpace((elemWidth + horzElementSpacing) * extraElements + extraRowSpace); main.AddFlexibleSpace(); } for (int i = 0; i < entries.Count; i++) { LibraryGUIEntry guiEntry = entries[i]; guiEntry.Initialize(); } }
// read one package private async Task <Pair <ResourcePackage, PackageHeader> > readPackage(PackageHeader packageHeader) { Pair <ResourcePackage, PackageHeader> pair = new Pair <ResourcePackage, PackageHeader>(); //read packageHeader ResourcePackage resourcePackage = new ResourcePackage(packageHeader); pair.setLeft(resourcePackage); //= new Pair<ResourcePackage, PackageHeader>(resourcePackage, null); //pair. = resourcePackage; //.setLeft(resourcePackage); long beginPos = buffer.position(); // read type string pool if (packageHeader.getTypeStrings() > 0) { buffer.position((int)(beginPos + packageHeader.getTypeStrings() - packageHeader.getHeaderSize())); resourcePackage.setTypeStringPool(await ParseUtils.readStringPool(buffer, (StringPoolHeader)await readChunkHeader())); } //read key string pool if (packageHeader.getKeyStrings() > 0) { buffer.position((int)(beginPos + packageHeader.getKeyStrings() - packageHeader.getHeaderSize())); resourcePackage.setKeyStringPool(await ParseUtils.readStringPool(buffer, (StringPoolHeader)await readChunkHeader())); } //outer: while (buffer.hasRemaining()) { ChunkHeader chunkHeader = await readChunkHeader(); long chunkBegin = buffer.position(); switch (chunkHeader.getChunkType()) { case ChunkType.TABLE_TYPE_SPEC: TypeSpecHeader typeSpecHeader = (TypeSpecHeader)chunkHeader; long[] entryFlags = new long[(int)typeSpecHeader.getEntryCount()]; for (int i = 0; i < typeSpecHeader.getEntryCount(); i++) { entryFlags[i] = Buffers.readUInt(buffer); } TypeSpec typeSpec = new TypeSpec(typeSpecHeader); typeSpec.setEntryFlags(entryFlags); //id start from 1 typeSpec.setName(resourcePackage.getTypeStringPool() .get(typeSpecHeader.getId() - 1)); resourcePackage.addTypeSpec(typeSpec); buffer.position((int)(chunkBegin + typeSpecHeader.getBodySize())); break; case ChunkType.TABLE_TYPE: TypeHeader typeHeader = (TypeHeader)chunkHeader; // read offsets table long[] offsets = new long[(int)typeHeader.getEntryCount()]; for (int i = 0; i < typeHeader.getEntryCount(); i++) { offsets[i] = Buffers.readUInt(buffer); } RType type = new RType(typeHeader); type.setName(resourcePackage.getTypeStringPool().get(typeHeader.getId() - 1)); long entryPos = chunkBegin + typeHeader.getEntriesStart() - typeHeader.getHeaderSize(); buffer.position((int)entryPos); ByteBuffer b = await buffer.slice(); await b.order(byteOrder); type.setBuffer(b); type.setKeyStringPool(resourcePackage.getKeyStringPool()); type.setOffsets(offsets); type.setStringPool(stringPool); resourcePackage.addType(type); locales.Add(type.getLocale()); buffer.position((int)(chunkBegin + typeHeader.getBodySize())); break; case ChunkType.TABLE_PACKAGE: // another package. we should read next package here //pair = new Pair<ResourcePackage, PackageHeader>(pair.Key, (PackageHeader)chunkHeader); pair.setRight((PackageHeader)chunkHeader); //break outer; return(pair); case ChunkType.TABLE_LIBRARY: // read entries LibraryHeader libraryHeader = (LibraryHeader)chunkHeader; for (long i = 0; i < libraryHeader.getCount(); i++) { int packageId = buffer.getInt(); string name = await Buffers.readZeroTerminatedString(buffer, 128); LibraryEntry entry = new LibraryEntry(packageId, name); //TODO: now just skip it.. } buffer.position((int)(chunkBegin + chunkHeader.getBodySize())); break; default: throw new Exception("unexpected chunk type: 0x" + chunkHeader.getChunkType()); } } return(pair); }
/// <summary> /// Sorts the specified set of project library entries by type (folder or resource), followed by name. /// </summary> /// <param name="input">Set of project library entries to sort.</param> private static void SortEntries(LibraryEntry[] input) { Array.Sort(input, (x, y) => { if (x.Type == y.Type) return x.Name.CompareTo(y.Name); else return x.Type == LibraryEntryType.File ? 1 : -1; }); }
/// <summary> /// Rebuilds the library window GUI. Should be called any time the active folder or contents change. /// </summary> private void Refresh() { requiresRefresh = false; LibraryEntry[] entriesToDisplay = new LibraryEntry[0]; if (IsSearchActive) { entriesToDisplay = ProjectLibrary.Search("*" + searchQuery + "*"); } else { DirectoryEntry entry = ProjectLibrary.GetEntry(CurrentFolder) as DirectoryEntry; if (entry == null) { CurrentFolder = ProjectLibrary.Root.Path; entry = ProjectLibrary.GetEntry(CurrentFolder) as DirectoryEntry; } if(entry != null) entriesToDisplay = entry.Children; } inProgressRenameElement = null; RefreshDirectoryBar(); SortEntries(entriesToDisplay); Rect2I visibleContentBounds = GetScrollAreaBounds(); content.Refresh(viewType, entriesToDisplay, visibleContentBounds); foreach (var path in cutPaths) content.MarkAsCut(path, true); foreach (var path in selectionPaths) content.MarkAsSelected(path, true); content.MarkAsPinged(pingPath, true); Rect2I contentBounds = content.Bounds; contentBounds.height = Math.Max(contentBounds.height, visibleContentBounds.height); GUIButton catchAll = new GUIButton("", EditorStyles.Blank); catchAll.Bounds = contentBounds; catchAll.OnClick += OnCatchAllClicked; catchAll.SetContextMenu(entryContextMenu); content.Underlay.AddElement(catchAll); Rect2I focusBounds = contentBounds; // Contents + Folder bar Rect2I scrollBounds = contentScrollArea.Bounds; focusBounds.x += scrollBounds.x; focusBounds.y += scrollBounds.y; Rect2I folderBarBounds = folderListLayout.Bounds; focusBounds.y -= folderBarBounds.height; focusBounds.height += folderBarBounds.height; GUIButton focusCatcher = new GUIButton("", EditorStyles.Blank); focusCatcher.Blocking = false; focusCatcher.OnFocusGained += () => hasContentFocus = true; focusCatcher.OnFocusLost += () => hasContentFocus = false; focusCatcher.Bounds = focusBounds; GUIPanel focusPanel = GUI.AddPanel(-3); focusPanel.AddElement(focusCatcher); UpdateDragSelection(dragSelectionEnd); }
private void FillTables() { var firstClient = new Client { FullName = "Наруто Удзумаки", IsDebtor = false }; var secondClient = new Client { FullName = "Саске Учиха", IsDebtor = true }; var thirdClient = new Client { FullName = "Олег Сергеевич", IsDebtor = true }; var firstAuthor = new Author { FullName = "Джирайя" }; var secondAuthor = new Author { FullName = "Джоан Роулинг" }; var thirdAuthor = new Author { FullName = "Масаши Кишимото" }; var firstBook = new Book { TitleName = "Наруто: Ураганные Хроники" }; var secondBook = new Book { TitleName = "Гарри Поттер" }; var thirdBook = new Book { TitleName = "Наруто Поттер, тактика" }; var fourthBook = new Book { TitleName = "Приди, приди, тактика" }; var firstBooksAuthors = new BooksAuthors { Book = firstBook, Author = thirdAuthor }; var secondBooksAuthors = new BooksAuthors { Book = secondBook, Author = secondAuthor }; var thirdBooksAuthors = new BooksAuthors { Book = thirdBook, Author = firstAuthor }; var fourthBooksAuthors = new BooksAuthors { Book = fourthBook, Author = firstAuthor }; var firstEntry = new LibraryEntry { Book = firstBook, Client = firstClient, ReturnDate = DateTime.Now }; var secondEntry = new LibraryEntry { Book = secondBook, Client = firstClient, ReturnDate = DateTime.Now }; var thirdEntry = new LibraryEntry { Book = thirdBook, Client = secondClient, ReturnDate = DateTime.Now }; context.BooksAuthors.AddRange( new BooksAuthors { Book = thirdBook, Author = secondAuthor }, thirdBooksAuthors, new BooksAuthors { Book = thirdBook, Author = thirdAuthor }); context.Clients.AddRange(firstClient, secondClient, thirdClient); context.Authors.AddRange(firstAuthor, secondAuthor, thirdAuthor); context.Books.AddRange(firstBook, secondBook, thirdBook, fourthBook); context.BooksAuthors.AddRange(firstBooksAuthors, secondBooksAuthors, fourthBooksAuthors); context.LibraryEntries.AddRange(firstEntry, secondEntry, thirdEntry); context.SaveChanges(); }
public PlaybackHistoryEntry( LibraryEntry libraryEntry) : this(libraryEntry, DateTime.Now) { }