示例#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>
        /// Updates the element.
        /// </summary>
        protected override void UpdateCore()
        {
            DateTime currentTime = this.MiyagiSystem.LastUpdate;

            if (this.Visible &&
                this.showStartTime.Ticks > 0 &&
                this.Style.DisplayDuration > TimeSpan.Zero &&
                currentTime - this.showStartTime > this.Style.DisplayDuration)
            {
                this.Hide();
                return;
            }

            if (!this.Visible)
            {
                if (!string.IsNullOrEmpty(this.Owner.ToolTipText) &&
                    this.mouseEnterTime.Ticks > 0 &&
                    currentTime - this.mouseEnterTime > this.Style.HoverDuration)
                {
                    this.Show();
                }
            }
            else
            {
                if (this.NeedsUpdate &&
                    IsBitmapTooltip)
                {
                    Size oldSize = Size;
                    if (bitmap == null)
                    {
                        Bitmap = Style.BitmapCreatorFunction(this.Owner.ToolTipText, Style.MaximumWidth);
                    }

                    this.NeedsUpdate = false;
                    this.ConvertBitmap();

                    this.InnerTextureElement.Size = new Size(this.Bitmap.Width, this.Bitmap.Height);

                    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;

                    this.InnerTextureElement.Texture = this.Bitmap != null
                                                      ? new Texture(this.TextureName)
                                                      : null;

                    this.bitmap.Dispose();
                    this.bitmap = null;

                    SetElementsSizes();
                }

                if (this.UpdateType.IsFlagSet(UpdateTypes.Opacity))
                {
                    this.TextureElement1.ApplyOpacity();
                    this.TextureElement2.ApplyOpacity();
                    this.TextureElement3.ApplyOpacity();
                    this.TextureElement4.ApplyOpacity();
                    this.TextureElement5.ApplyOpacity();
                    this.TextureElement6.ApplyOpacity();
                    this.TextureElement7.ApplyOpacity();
                    this.TextureElement8.ApplyOpacity();
                    this.TextureElement9.ApplyOpacity();
                    if (this.InnerTextureElement != null)
                    {
                        this.InnerTextureElement.ApplyOpacity();
                    }
                }


                ForEachActiveElement(ele => ele.Update());
            }
        }