예제 #1
0
 protected bool Equals(CommandButtonPropMask other)
 {
     return(HasForeColor == other.HasForeColor && HasBackColor == other.HasBackColor && HasVariousPropertyBits == other.HasVariousPropertyBits &&
            HasCaption == other.HasCaption && HasPicturePosition == other.HasPicturePosition && HasSize == other.HasSize &&
            HasMousePointer == other.HasMousePointer && HasPicture == other.HasPicture && HasAccelerator == other.HasAccelerator &&
            TakeFocusOnClick == other.TakeFocusOnClick && HasMouseIcon == other.HasMouseIcon);
 }
예제 #2
0
        public CommandButtonControl(byte[] b)
        {
            using (var st = new MemoryStream(b))
                using (var r = new FrxReader(st)) {
                    MinorVersion = r.ReadByte();
                    MajorVersion = r.ReadByte();

                    var cbCommandButton = r.ReadUInt16();
                    PropMask = new CommandButtonPropMask(r.ReadUInt32());

                    // DataBlock
                    ForeColor           = PropMask.HasForeColor ? r.ReadOleColor() : null;
                    BackColor           = PropMask.HasBackColor ? r.ReadOleColor() : null;
                    VariousPropertyBits = PropMask.HasVariousPropertyBits ? r.ReadUInt32() : 0;
                    var captionCcb = PropMask.HasCaption ? r.ReadCcb() : Tuple.Create(0, false);
                    PicturePosition = PropMask.HasPicturePosition ? r.ReadPicturePosition() : PicturePosition.RightTop;
                    MousePointer    = PropMask.HasMousePointer ? r.ReadMousePointer() : MousePointer.Arrow;
                    if (PropMask.HasPicture)
                    {
                        r.Skip2Bytes();
                    }
                    Accelerator = PropMask.HasAccelerator ? r.ReadWChar() : "";
                    if (PropMask.HasMouseIcon)
                    {
                        r.Skip2Bytes();
                    }

                    // ExtraDataBlock
                    Caption = r.ReadStringFromCcb(captionCcb);
                    Size    = PropMask.HasSize ? r.ReadCoords() : Tuple.Create(0, 0);

                    r.AlignTo(4);
                    if (cbCommandButton != r.BaseStream.Position - 4)
                    {
                        throw new ApplicationException("Error reading 'o' stream in .frx data: expected cbCommandButton size "
                                                       + $"{r.BaseStream.Position - 4}, but actual size was {cbCommandButton}.");
                    }

                    // StreamData
                    Picture   = PropMask.HasPicture ? r.ReadGuidAndPicture() : new byte[0];
                    MouseIcon = PropMask.HasMouseIcon ? r.ReadGuidAndPicture() : new byte[0];

                    TextProps = r.ReadTextProps();
                }
        }