Exemple #1
0
        public static void ShowToolTip(Point point, string text, bool force = false)
        {
            //if (force || WindowFocused || (EmoteList?.ContainsFocus ?? false))
            {
                if (ToolTip == null)
                {
                    ToolTip = new Controls.ToolTip()
                    {
                        Enabled = false
                    };
                }

                Screen.FromPoint(point);

                var screen = Screen.FromPoint(Cursor.Position);

                ToolTip.TooltipText = text;

                if (!ToolTip.Visible)
                {
                    ToolTip.Show();
                }

                int x = point.X, y = point.Y;

                if (point.X < screen.WorkingArea.X)
                {
                    x = screen.WorkingArea.X;
                }
                else if (point.X + ToolTip.Width > screen.WorkingArea.Right)
                {
                    x = screen.WorkingArea.Right - ToolTip.Width;
                }

                if (point.Y < screen.WorkingArea.Y)
                {
                    y = screen.WorkingArea.Y;
                }
                else if (point.Y + ToolTip.Height > screen.WorkingArea.Bottom)
                {
                    y = y - 24 - ToolTip.Height;
                }

                point = new Point(x, y);

                if (ToolTip.Location != point)
                {
                    ToolTip.Location = point;
                }
            }
        }
Exemple #2
0
        public static void ShowToolTip(Point point, string text, string imgurl, LazyLoadedImage tooltipimage, bool force = false)
        {
            //if (force || WindowFocused || (EmoteList?.ContainsFocus ?? false))

            try
            {
                lock (tooltiplock) {
                    if (ToolTip == null)
                    {
                        ToolTip = new Controls.ToolTip()
                        {
                            Enabled = false
                        };
                    }
                }

                lock (ToolTip) {
                    ToolTip.TooltipText = text;
                }
                if (AppSettings.ShowEmoteTooltip && !String.IsNullOrEmpty(imgurl) && (ToolTip.Image == null || !ToolTip.Image.Url.Equals(imgurl)))
                {
                    LazyLoadedImage img;
                    if (tooltipimage != null)
                    {
                        img = tooltipimage;
                    }
                    else
                    {
                        img     = new LazyLoadedImage();
                        img.Url = imgurl;
                    }
                    img.ImageLoaded += (s, e) => {
                        lock (ToolTip) {
                            point = calcTooltipLocation(point);
                            if (ToolTip.Location != point)
                            {
                                ToolTip.Location = point;
                            }
                            ToolTip.redraw();
                        }
                    };
                    lock (ToolTip) {
                        ToolTip.Image = img;
                    }
                }
                else if (String.IsNullOrEmpty(imgurl))
                {
                    lock (ToolTip) {
                        ToolTip.Image = null;
                    }
                }
                lock (ToolTip) {
                    if (!ToolTip.Visible)
                    {
                        ToolTip.Show();
                        SetWindowPos(ToolTip.Handle.ToInt32(), HWND_TOPMOST,
                                     ToolTip.Left, ToolTip.Top, ToolTip.Width, ToolTip.Height,
                                     SWP_NOACTIVATE);
                    }

                    point = calcTooltipLocation(point);

                    if (ToolTip.Location != point)
                    {
                        ToolTip.Location = point;
                    }
                }
            } catch (Exception e) {
                GuiEngine.Current.log("exception loading tooltip " + e.ToString());
            }
        }