Пример #1
0
        public void Show()
        {
            if (this.Owner.MiyagiSystem == null)
            {
                return;
            }

            if (!this.Visible)
            {
                if (IsBitmapTooltip &&
                    Bitmap == null)
                {
                    Bitmap = Style.BitmapCreatorFunction(this.Owner.ToolTipText, Style.MaximumWidth);
                }

                MiyagiSystem system = this.Owner.MiyagiSystem;

                system.GUIManager.SetToolTip(this);
                this.SetVisible(true);

                // set the new size
                //var newSize = this.size = this.Style.TextStyle.Font.MeasureString(this.Owner.ToolTipText, Size.Empty, this.Owner.ToolTipText.Contains(Environment.NewLine));
                var newSize = Size.Empty;
                if (IsBitmapTooltip)
                {
                    newSize = new Common.Data.Size(Bitmap.Size.Width, Bitmap.Size.Height);
                }
                else
                {
                    newSize = this.Style.TextStyle.Font.MeasureString(this.Owner.ToolTipText, Size.Empty, true) + new Size(0, 2);
                }

                this.size = newSize;

                SetLocation();
                SetElementsSizes();

                // start the fadecontroller
                this.opacity = 1;

                if (this.fadeController != null)
                {
                    this.fadeController.Stop();
                }

                if (this.Style.FadeInDuration > TimeSpan.Zero)
                {
                    this.fadeController = new LinearFunctionValueController <float>(0, 1, this.Style.FadeInDuration);
                    this.fadeController.Start(system, true, this.SetOpacity);
                }

                this.showStartTime = this.MiyagiSystem.LastUpdate;
            }
        }
Пример #2
0
        /// <summary>
        /// Releases the unmanaged resources used by the element.
        /// </summary>
        /// <param name="disposing">Whether Dispose has been called.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.Hide();

                if (this.fadeController != null)
                {
                    this.fadeController.Stop();
                    this.fadeController = null;
                }

                RemoveTexture();

                if (this.bitmap != null)
                {
                    this.bitmap.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Пример #3
0
        /// <summary>
        /// Hides the tooltip.
        /// </summary>
        public void Hide()
        {
            if (this.Owner.MiyagiSystem == null)
            {
                return;
            }

            if (this.Visible)
            {
                if (this.fadeController != null)
                {
                    this.fadeController.Stop();
                    this.fadeController = null;
                }

                this.SetVisible(false);

                if (this.Owner.MiyagiSystem.GUIManager.CurrentToolTip == this)
                {
                    this.Owner.MiyagiSystem.GUIManager.HideToolTip();
                }
                else if (!AreAllSpritesNull())
                {
                    this.RemoveSprite();
                }


                this.mouseEnterTime = DateTime.MinValue;
                this.showStartTime  = DateTime.MinValue;
                if (this.bitmap != null)
                {
                    this.bitmap.Dispose();
                    this.bitmap = null;
                }

                RemoveTexture();
            }
        }