/** * \brief <b>Brief Description</b> - DisplayFooterContent <b><i>class method</i></b> - Displays the content of the footer * \details <b>Details</b> * * This takes in the flag with what buttons should be displayed and whether the content box is shown * * \return <b>void</b> */ public static void DisplayFooterContent(FooterFlags flags, bool isConetentBoxShown = false) { // create the top part of the container string topBar = string.Format("{0}{1}{2}{3}{4}", TLCORNER, "".PadRight(24, HORIZONTAL), MJOINT, "".PadRight(Console.WindowWidth - 28, HORIZONTAL), TRCORNER); // if the content box is shown give the top bar of the footer some extra joints in order to connect if (isConetentBoxShown) { topBar = string.Format("{0}{1}{2}{3}{4}{5}{6}", TLCORNER, "".PadRight(24, HORIZONTAL), MJOINT, HORIZONTAL, MJOINT, "".PadRight(Console.WindowWidth - 30, HORIZONTAL), RJOINT); } Console.WriteLine(topBar); // set the buttons based on the flags string back = ((flags & FooterFlags.Back) != 0) ? "ESC[BACK]" : ""; string quit = ((flags & FooterFlags.Quit) != 0) ? "F9[QUIT]" : ""; // build the footer content depending on what buttons were passed in string footer = (quit == "") ? string.Format("{0} {1}{2} {3}", Container.VERTICAL, back.PadRight(Console.WindowWidth / 2), quit.PadLeft(Console.WindowWidth / 2), Container.VERTICAL) : string.Format("{0} {1}{2} {3}", Container.VERTICAL, back.PadRight(20, ' '), quit.PadLeft(Console.WindowWidth - quit.Length - 17, ' '), Container.VERTICAL); // display the footer Console.WriteLine(footer); Console.WriteLine(string.Format("{0}{1}{2}", BLCORNER, "".PadRight(Console.WindowWidth - 3, HORIZONTAL), BRCORNER)); }
private ByteVector Render(bool isHeader) { ByteVector v = new ByteVector(); v.Add(FileIdentifier); v.Add(ByteVector.FromUInt(2000, false)); v.Add(ByteVector.FromUInt(tag_size, false)); v.Add(ByteVector.FromUInt(item_count, false)); uint flags = 0; if ((Flags & FooterFlags.HeaderPresent) != 0) { flags |= (uint)FooterFlags.HeaderPresent; } if (isHeader) { flags |= (uint)FooterFlags.IsHeader; } else { flags &= (uint)~FooterFlags.IsHeader; } v.Add(ByteVector.FromUInt(flags, false)); v.Add(ByteVector.FromULong(0)); return(v); }
public Footer(ByteVector data) { if (data == null) { throw new ArgumentNullException("data"); } if (data.Count < Size) { throw new CorruptFileException("Provided data is smaller than object size."); } if (!data.StartsWith(FileIdentifier)) { throw new CorruptFileException("Provided data does not start with File Identifier"); } version = data.Mid(8, 4).ToUInt(false); tag_size = data.Mid(12, 4).ToUInt(false); item_count = data.Mid(16, 4).ToUInt(false); flags = (FooterFlags)data.Mid(20, 4).ToUInt(false); }
/// <summary> /// Renders the current instance as either an APE tag header /// or footer. /// </summary> /// <param name="isHeader"> /// A <see cref="bool" /> value indicating whether or not the /// current instance is to be rendered as a header. /// </param> /// <returns> /// A <see cref="ByteVector" /> object containing the /// rendered version of the current instance. /// </returns> private ByteVector Render(bool isHeader) { ByteVector v = new ByteVector(); // add the file identifier -- "APETAGEX" v.Add(FileIdentifier); // add the version number -- we always render a 2.000 // tag regardless of what the tag originally was. v.Add(ByteVector.FromUInt(2000, false)); // add the tag size v.Add(ByteVector.FromUInt(tag_size, false)); // add the item count v.Add(ByteVector.FromUInt(item_count, false)); // render and add the flags uint flags = 0; if ((Flags & FooterFlags.HeaderPresent) != 0) { flags |= (uint)FooterFlags.HeaderPresent; } // footer is always present if (isHeader) { flags |= (uint)FooterFlags.IsHeader; } else { flags &= (uint)~FooterFlags.IsHeader; } v.Add(ByteVector.FromUInt(flags, false)); // add the reserved 64bit v.Add(ByteVector.FromULong(0)); return(v); }