Example #1
0
 public void Dispose()
 {
     if (ThumbImg != null)
     {
         ThumbImg.Dispose();
     }
 }
Example #2
0
        public UILotButton()
        {
            DataService = FSOFacade.Kernel.Get <IClientDataService>();

            NameLabel                   = new UILabel();
            NameLabel.Y                 = 52;
            NameLabel.X                 = 2;
            NameLabel.Alignment         = TextAlignment.Center;
            NameLabel.Size              = new Vector2(76, 40);
            NameLabel.CaptionStyle      = NameLabel.CaptionStyle.Clone();
            NameLabel.CaptionStyle.Size = 9;
            NameLabel.Wrapped           = true;
            Add(NameLabel);

            Target = new Binding <Lot>()
                     .WithBinding(this, "NameLabel.Caption", "Lot_Name")
                     .WithBinding(this, "ThumbImg", "Lot_Thumbnail", x =>
            {
                if (ThumbImg != null)
                {
                    ThumbImg.Dispose();
                }
                var thumb = ((cTSOGenericData)x)?.Data;
                if (((thumb?.Length) ?? 0) == 0)
                {
                    return(null);
                }
                return(ImageLoader.FromStream(GameFacade.GraphicsDevice, new MemoryStream(thumb)));
            })
                     .WithBinding(this, "BgImg", "Lot_IsOnline", x =>
            {
                var online = (bool)x;
                return(GetTexture((ulong)((online) ? 0xC000000002 : 0xC200000002)));
            })
                     .WithBinding(this, "HoverImg", "Lot_IsOnline", x =>
            {
                var online = (bool)x;
                return(GetTexture((ulong)((online) ? 0xC100000002 : 0xC300000002)));
            });
            m_TooltipHandler = UIUtils.GiveTooltip(this);

            ClickHandler =
                ListenForMouse(new Rectangle(0, 0, 80, 50), new UIMouseEvent(OnMouseEvent));
        }