GetScreen() public static method

public static GetScreen ( ) : Screen
return System.Windows.Forms.Screen
Beispiel #1
0
        public static void ShowHUD(string param)
        {
            BaseHUD hud = null;

            param = filterName(param);
            switch (param)
            {
            case "healthbar":
                hud = new HealthBar();
                break;

            case "manabar":
                hud = new ManaBar();
                break;

            case "experiencebar":
                hud = new ExperienceBar();
                break;

            case "curvedbar":
            case "curvedbars":
                hud = new CurvedHUD();
                break;

            case "healthlist":
                hud = new HealthList();
                break;

            case "portrait":
                hud = new Portrait();
                break;
            }
            if (hud == null)
            {
                return;
            }
            string hudName   = hud.GetHUD();
            string entryName = filterName(hud.GetHUD());

            lock (huds) {
                if (huds.ContainsKey(entryName))
                {
                    huds[entryName].Close();
                    huds.Remove(entryName);
                }
                huds.Add(entryName, hud);
                int x      = SettingsManager.getSettingInt(hudName + "XOffset");
                int y      = SettingsManager.getSettingInt(hudName + "YOffset");
                int width  = SettingsManager.getSettingInt(hudName + "Width");
                int height = SettingsManager.getSettingInt(hudName + "Height");
                int anchor = SettingsManager.getSettingInt(hudName + "Anchor");

                width  = width < 0 ? 280 : width;
                height = height < 0 ? 60 : height;

                int    position_x = 0, position_y = 0;
                Screen screen  = ProcessManager.GetScreen();
                int    xOffset = x == -1 ? 30 : x;
                int    yOffset = y == -1 ? 30 : y;
                switch (anchor)
                {
                case 4:
                    position_x = (screen.WorkingArea.Left + screen.WorkingArea.Width / 2) + xOffset - width / 2;
                    position_y = (screen.WorkingArea.Top + screen.WorkingArea.Height / 2) + yOffset - height / 2;
                    break;

                case 3:
                    position_x = screen.WorkingArea.Right - xOffset - width;
                    position_y = screen.WorkingArea.Bottom - yOffset - height;
                    break;

                case 2:
                    position_x = screen.WorkingArea.Left + xOffset;
                    position_y = screen.WorkingArea.Bottom - yOffset - height;
                    break;

                case 1:
                    position_x = screen.WorkingArea.Right - xOffset - width;
                    position_y = screen.WorkingArea.Top + yOffset;
                    break;

                default:
                    position_x = screen.WorkingArea.Left + xOffset;
                    position_y = screen.WorkingArea.Top + yOffset;
                    break;
                }
                hud.Width  = width;
                hud.Height = height;

                hud.LoadHUD();

                hud.StartPosition = FormStartPosition.Manual;
                hud.SetDesktopLocation(position_x, position_y);
                hud.TopMost = true;
                hud.Show();
            }
        }
Beispiel #2
0
        public static void ShowNotification(NotificationForm f, string command, string screenshot_path = "")
        {
            if (f == null)
            {
                return;
            }

            if (screenshot_path == "")
            {
                TibialyzerCommand cmd = new TibialyzerCommand(command);
                command_stack.Push(cmd);
                f.command = cmd;
            }
            f.Visible = false;
            int richX    = -1;
            int richY    = -1;
            int anchor   = 0;
            int duration = 5;
            int group    = 0;

            for (int it = 0; it < Constants.NotificationTypeObjects.Count; it++)
            {
                if (f.FormName() == Constants.NotificationTypeObjects[it])
                {
                    string settingObject = Constants.NotificationTypes[it].Replace(" ", "");
                    richX    = SettingsManager.getSettingInt(settingObject + "XOffset");
                    richY    = SettingsManager.getSettingInt(settingObject + "YOffset");
                    anchor   = SettingsManager.getSettingInt(settingObject + "Anchor");
                    duration = SettingsManager.getSettingInt(settingObject + "Duration");
                    group    = Math.Min(Math.Max(SettingsManager.getSettingInt(settingObject + "Group"), 0), 9);
                    break;
                }
            }
            f.notificationDuration = duration;
            f.LoadForm();
            if (screenshot_path != "")
            {
                Bitmap bitmap = new Bitmap(f.Width, f.Height);
                f.DrawToBitmap(bitmap, new Rectangle(0, 0, f.Width, f.Height));
                foreach (Control c in f.Controls)
                {
                    c.DrawToBitmap(bitmap, new Rectangle(new Point(Math.Min(Math.Max(c.Location.X, 0), f.Width), Math.Min(Math.Max(c.Location.Y, 0), f.Height)), c.Size));
                }
                bitmap.Save(screenshot_path);
                bitmap.Dispose();
                f.Dispose();
                return;
            }
            if (NotificationFormGroups[group] != null)
            {
                NotificationFormGroups[group].close();
            }
            int    position_x = 0, position_y = 0;
            Screen screen = ProcessManager.GetScreen();

            int xOffset = richX == -1 ? 30 : richX;
            int yOffset = richY == -1 ? 30 : richY;

            switch (anchor)
            {
            case 3:
                position_x = screen.WorkingArea.Right - xOffset - f.Width;
                position_y = screen.WorkingArea.Bottom - yOffset - f.Height;
                break;

            case 2:
                position_x = screen.WorkingArea.Left + xOffset;
                position_y = screen.WorkingArea.Bottom - yOffset - f.Height;
                break;

            case 1:
                position_x = screen.WorkingArea.Right - xOffset - f.Width;
                position_y = screen.WorkingArea.Top + yOffset;
                break;

            default:
                position_x = screen.WorkingArea.Left + xOffset;
                position_y = screen.WorkingArea.Top + yOffset;
                break;
            }

            f.StartPosition = FormStartPosition.Manual;
            f.SetDesktopLocation(position_x, position_y);
            f.TopMost = true;
            f.Show();
            NotificationFormGroups[group] = f;
        }
Beispiel #3
0
        public static void ShowSimpleNotification(SimpleNotification f)
        {
            lock (popupLock) {
                if (popupContainer != null)
                {
                    popupContainer.ShowNotification(f);
                    return;
                }

                int    position_x = 0, position_y = 0;
                Screen screen  = ProcessManager.GetScreen();
                int    simpleX = SettingsManager.getSettingInt("SimpleNotificationXOffset");
                int    simpleY = SettingsManager.getSettingInt("SimpleNotificationYOffset");

                int xOffset      = simpleX < 0 ? 30 : simpleX;
                int yOffset      = simpleY < 0 ? 30 : simpleY;
                int anchor       = SettingsManager.getSettingInt("SimpleNotificationAnchor");
                int sign         = 1;
                int basePosition = screen.WorkingArea.Bottom - yOffset;
                int startX       = 0;
                switch (anchor)
                {
                case 0:
                case 1:
                    // Top
                    sign         = -1;
                    basePosition = screen.WorkingArea.Top + yOffset;
                    break;

                case 2:
                default:
                    // Bottom
                    break;
                }
                switch (anchor)
                {
                case 0:
                case 2:
                    // Left
                    position_x = screen.WorkingArea.Left + xOffset;
                    startX     = position_x - (f.Width + notificationSpacing);
                    break;

                case 1:
                default:
                    // Right
                    position_x = screen.WorkingArea.Right - f.Width - notificationSpacing - xOffset;
                    startX     = position_x + f.Width + notificationSpacing;
                    break;
                }

                foreach (SimpleNotification notification in notificationStack)
                {
                    basePosition -= sign * (notification.Height + notificationSpacing);
                }
                position_y      = basePosition - sign * f.Height;
                f.StartPosition = FormStartPosition.Manual;
                if (!SettingsManager.getSettingBool("EnableSimpleNotificationAnimation"))
                {
                    startX = position_x;
                }

                f.SetDesktopLocation(startX, position_y);
                f.targetPositionX = position_x;
                f.targetPositionY = position_y;
                f.FormClosed     += simpleNotificationClosed;

                notificationStack.Add(f);

                f.TopMost = true;
                f.Show();
            }
        }