创建一个看起来像Windows显示设置屏幕的图像 [英] Create an image that looks like the windows display settings screen

查看:90
本文介绍了创建一个看起来像Windows显示设置屏幕的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



有没有人看过以编程方式重新创建显示器布局,如Windows中的显示设置对话框所示?我说的是显示所有显示器的屏幕,以及它们相对于彼此的位置。在Windows 10上,右键单击桌面并选择显示设置即可实现此目的。在Windows 7上,右键单击桌面并选择屏幕分辨率。



现在人们可以拥有复杂的布局,并且知道他们使用的配置可以派上用场一些案例。虽然通过迭代System.Windows.Forms.Screens.AllScreens(特别是Screen.Bounds)来获取描述布局的所有*值*是微不足道的,但是可视化这些数字会变得相当困难,尤其是当您有超过2个监视器时你抛出负坐标。



我的问题:有没有人试过用这些值来渲染图像?显然我不想要1:1的东西;我所追求的只是一个小小的缩略图。奖励,如果它可以显示每个监视器的左上角/右下角的坐标,并通过名称(Screen.DeviceName)识别它们,甚至可能显示任务栏停靠在每个监视器的哪一侧(可以通过屏幕推断)。 Bounds vs Screen.WorkingArea)。



所有的数据都在那里......我只是没有耐心坐下来用笔和纸准确弄清楚如何使用GDI渲染所有元素,然后将其转换为图像(严格来说,我甚至不想将其渲染到屏幕,我想生成一个图像,以便将其保存到磁盘)。



我尝试了什么:



全部在System.Windows.Forms.Screens中.AllScreens ...我只是不知道从哪里开始渲染所有矩形,并将最终结果转换为图像。

Hi all,

Has anyone ever looked at programmatically recreating the monitor layout as shown by the Display Settings dialog box in Windows? I'm talking about the screen that shows all your monitors, and how they're positioned relative to each other. On Windows 10, you get there by right-clicking on the desktop and selecting Display Settings. On Windows 7, you right-click on the desktop and select Screen Resolution.

People can have complex layouts nowadays, and knowing what configuration they use can come in handy in some cases. While it's trivial to get all the *values* that describe the layout by iterating over System.Windows.Forms.Screens.AllScreens (specifically, Screen.Bounds), visualizing those numbers can get rather difficult, especially when you have more than 2 monitors, and you throw in negative coordinates on top of that.

My question: Has anyone ever tried to use those values to render an Image from them? Obviously I wouldn't want something that's 1:1; a small-ish thumbnail is all I'm after. Bonus if it can display coordinates at each monitor's top-left/bottom-right corners and identify them by name (Screen.DeviceName), and perhaps even show what side of each monitor the taskbar is docked on (which can be inferred through Screen.Bounds vs Screen.WorkingArea).

All the data's there...I just don't have the patience to sit down with pen and paper and figure out exactly how to render all the elements using GDI, and then turn that into an Image (strictly speaking, I'm not even trying to render it to screen, I want to generate an Image so it can be saved to disk).

What I have tried:

It's all in System.Windows.Forms.Screens.AllScreens...I just don't know where to start to render all the rectangles, and turn the final results into an Image.

推荐答案

引用:

我只是没有耐心和pe坐下来n和纸,并确切地弄清楚如何使用GDI渲染所有元素

I just don't have the patience to sit down with pen and paper and figure out exactly how to render all the elements using GDI

然后我怀疑这个应用程序不会发生:如果你不能打扰做这项工作,为什么你认为我们会想要为你做这件事吗?



如果你想让别人写你的代码,你必须付钱 - 我建议你去Freelancer.com并问那里。 br $> b $ b

但要注意:你得到的是你付出的代价。支付花生,买猴子。



发展的概念就像这句话所暗示的那样:系统地运用科学和技术知识来满足特定的目标或要求。 BusinessDictionary.com [ ^ ]

这与有一个不一样快速谷歌并放弃,如果我找不到完全正确的代码。

所以要么付钱给别人去做,要么学会如何自己写。我们不是来为你做这件事。

Then I suspect that this app isn't going to happen: if you can't be bothered to do the work, why would you think we would want to do it for you?

If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.

But be aware: you get what you pay for. Pay peanuts, get monkeys.

The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
So either pay someone to do it, or learn how to write it yourself. We aren't here to do it for you.


这应该有希望让你开始



This should hopefully get you started

static void Main(string[] args)
{
    // 120 x 120 thumbnail
    Bitmap image = new Bitmap(120, 120);

    Graphics g = Graphics.FromImage(image);
    g.Clear(Color.White);

    Pen p = new Pen(Color.Black, 3);

    // Primary display
    g.DrawLine(p, PrimaryDisplayEnabled(image), PrimaryDisplayDisabled(image));

    // Secondary display
    g.DrawLine(p, SecondaryDisplayEnabled(image), SecondaryDisplayDisabled(image));

    // Orientation
    g.DrawLine(p, OrientationLandscape(image), OrientationPortrait(image));

    // Resolution
    g.DrawEllipse(p, Resolution(image));

    image.Save(@"c:\temp\test.png", System.Drawing.Imaging.ImageFormat.Png);
}

private static Point PrimaryDisplayEnabled(Bitmap image)
{
    return new Point(image.Width - 110, image.Height - 110);
}

private static Point PrimaryDisplayDisabled(Bitmap image)
{
    return new Point(image.Width - 110, image.Height - 20);
}

private static Point SecondaryDisplayEnabled(Bitmap image)
{
    return new Point(image.Width - 110, image.Height - 110);
}

private static Point SecondaryDisplayDisabled(Bitmap image)
{
    return new Point((image.Width / 12) * 5 , image.Height - 20);
}

private static Point OrientationLandscape(Bitmap image)
{
    return new Point((image.Width / 12) * 5, (image.Width / 12) * 10);
}

private static Point OrientationPortrait(Bitmap image)
{
    return new Point((int)(image.Width * 1.5) - (image.Height + 10), 10);
}

private static Rectangle Resolution(Bitmap image)
{
    return new Rectangle((image.Width / 2) + 5, 10, image.Height / 3, 90);
}


Quote:

我的问题:有没有人有没有尝试过使用这些值来渲染图像?显然我不想要1:1的东西;我所追求的只是一个小小的缩略图。奖励,如果它可以显示每个监视器的左上角/右下角的坐标,并通过名称(Screen.DeviceName)识别它们,甚至可能显示任务栏停靠在每个监视器的哪一侧(可以通过屏幕推断)。 Bounds vs Screen.WorkingArea)。

My question: Has anyone ever tried to use those values to render an Image from them? Obviously I wouldn't want something that's 1:1; a small-ish thumbnail is all I'm after. Bonus if it can display coordinates at each monitor's top-left/bottom-right corners and identify them by name (Screen.DeviceName), and perhaps even show what side of each monitor the taskbar is docked on (which can be inferred through Screen.Bounds vs Screen.WorkingArea).



这可疑似乎是对其他人交出工作的一个薄薄的请求,所以你不必亲自去做。您认为该问题的答案是什么?


This suspiciously appears to be a thinly veiled request for other people to hand over their work so you don't have to do it yourself. What do you think the answer to that question is going to be?


这篇关于创建一个看起来像Windows显示设置屏幕的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆