/// <summary>
 ///     Write the menu item to a binary stream.
 /// </summary>
 /// <param name="w">Binary stream.</param>
 internal override void Write(BinaryWriter w)
 {
     base.Write(w);
     ResourceUtil.PadToDWORD(w);
     w.Write(_dwHelpId);
     _subMenuItems.Write(w);
 }
예제 #2
0
        /// <summary>
        ///     Write a string resource to a binary stream.
        /// </summary>
        /// <param name="w">Binary stream.</param>
        internal void Write(BinaryWriter w)
        {
            // write the block info
            var headerPos = w.BaseStream.Position;

            // wLength
            w.Write(_header.wLength);
            // wValueLength
            w.Write(_header.wValueLength);
            // wType
            w.Write(_header.wType);
            // szKey
            w.Write(Encoding.Unicode.GetBytes(_key));
            // null terminator
            w.Write((UInt16)0);
            // pad fixed info
            ResourceUtil.PadToDWORD(w);
            var valuePos = w.BaseStream.Position;

            if (_value != null)
            {
                // value (always double-null-terminated)
                w.Write(Encoding.Unicode.GetBytes(_value));
            }
            // wValueLength
            ResourceUtil.WriteAt(w, (w.BaseStream.Position - valuePos) / Marshal.SystemDefaultCharSize, headerPos + 2);
            // wLength
            ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos);
        }
예제 #3
0
 internal void WriteControls(BinaryWriter w)
 {
     foreach (var control in Controls)
     {
         ResourceUtil.PadToDWORD(w);
         control.Write(w);
     }
 }
예제 #4
0
 /// <summary>
 ///     Write the menu collection to a binary stream.
 /// </summary>
 /// <param name="w">Binary stream.</param>
 internal void Write(BinaryWriter w)
 {
     foreach (var menuItem in this)
     {
         ResourceUtil.PadToDWORD(w);
         menuItem.Write(w);
     }
 }
예제 #5
0
 /// <summary>
 ///     Write the menu item to a binary stream.
 /// </summary>
 /// <param name="w">Binary stream.</param>
 internal virtual void Write(BinaryWriter w)
 {
     // header
     w.Write(_header.dwType);
     w.Write(_header.dwState);
     w.Write(_header.dwMenuId);
     w.Write(_header.bResInfo);
     // menu string
     if (_menuString != null)
     {
         w.Write(Encoding.Unicode.GetBytes(_menuString));
         w.Write((UInt16)0);
         ResourceUtil.PadToDWORD(w);
     }
 }
예제 #6
0
 /// <summary>
 ///     Write the resource table.
 /// </summary>
 /// <param name="w">Binary stream.</param>
 internal virtual void Write(BinaryWriter w)
 {
     // wLength
     w.Write(_header.wLength);
     // wValueLength
     w.Write(_header.wValueLength);
     // wType
     w.Write(_header.wType);
     // write key
     w.Write(Encoding.Unicode.GetBytes(_key));
     // null-terminator
     w.Write((UInt16)0);
     // pad fixed info
     ResourceUtil.PadToDWORD(w);
 }
예제 #7
0
        /// <summary>
        ///     Write the string file-version resource to a binary stream.
        /// </summary>
        /// <param name="w">Binary stream.</param>
        internal override void Write(BinaryWriter w)
        {
            var headerPos = w.BaseStream.Position;

            base.Write(w);

            var stringsEnum = _strings.GetEnumerator();

            while (stringsEnum.MoveNext())
            {
                stringsEnum.Current.Value.Write(w);
            }

            ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos);
            ResourceUtil.PadToDWORD(w);
        }
예제 #8
0
        /// <summary>
        ///     Write the string table to a binary stream.
        /// </summary>
        /// <param name="w">Binary stream.</param>
        /// <returns>Last unpadded position.</returns>
        internal override void Write(BinaryWriter w)
        {
            var headerPos = w.BaseStream.Position;

            base.Write(w);

            var total       = _strings.Count;
            var stringsEnum = _strings.GetEnumerator();

            while (stringsEnum.MoveNext())
            {
                stringsEnum.Current.Value.Write(w);
                ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos);
                // total parent structure size must not include padding
                if (--total != 0)
                {
                    ResourceUtil.PadToDWORD(w);
                }
            }
        }
예제 #9
0
        /// <summary>
        ///     Write the table of language and code page identifier pairs to a binary stream.
        /// </summary>
        /// <param name="w">Binary stream.</param>
        /// <returns>Last unpadded position.</returns>
        internal override void Write(BinaryWriter w)
        {
            var headerPos = w.BaseStream.Position;

            base.Write(w);

            var languagesEnum = _languages.GetEnumerator();
            var valuePos      = w.BaseStream.Position;

            while (languagesEnum.MoveNext())
            {
                // id
                w.Write(languagesEnum.Current.Key);
                // code page
                w.Write(languagesEnum.Current.Value);
            }

            ResourceUtil.WriteAt(w, w.BaseStream.Position - valuePos, headerPos + 2);
            ResourceUtil.PadToDWORD(w);
            ResourceUtil.WriteAt(w, w.BaseStream.Position - headerPos, headerPos);
        }
예제 #10
0
 /// <summary>
 ///     Write fixed file information to a binary stream.
 /// </summary>
 /// <param name="w">Binary stream.</param>
 public void Write(BinaryWriter w)
 {
     w.Write(ResourceUtil.GetBytes(_fixedfileinfo));
     ResourceUtil.PadToDWORD(w);
 }