|
Hi,
I'm creating code to select monitor in a multi-monitor configuration. I was wondering if someone with many monitors could help me understand what is happening once you have 5-6 monitors connected to your PC by running this script and just reporting results it prints out.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Scr.Tests
{
class Program
{
static void Main(string[] args)
{
Rectangle desktop = SystemInformation.VirtualScreen;
Console.WriteLine(desktop.ToString());
Screen[] screens = Screen.AllScreens;
for (int i = 0; i < screens.Length; i++)
{
Console.WriteLine(screens[i].Bounds.ToString());
Console.WriteLine(screens[i].DeviceName);
Console.WriteLine(screens[i].WorkingArea.ToString());
}
}
}
}
Sincerely,
Tomaz
|
|
|
|
|
Your question is not clear here. What is about what is "printed out" by your code that you don't understand. Given the information produced by enumerating the Screens, what is you want to do ?
Given that more than one Screen can have (one or more) TaskBar objects, what does that mean in this context.
You are aware that 'ScreenPrimaryScreen() will return the current active device Window, and if you are enumerating multiple Screens, the Screen.Primary method will return a boolean value for a given Screen indicating whether it's Primary.
In any case, I think there's code on this post, and on this thread, on StackOverFlow you may find useful: [^]
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
Short answer is: I would like to draw monitor configuration on screen and I need test data sample to be able to resolve my dilemmas:
- which monitor is monitor 1 (is it always left, top?),
- can coordinates be negative,
- what if one monitor is "missiong" and hence rectangular virtual desktop has "holes" in it, how does mouse behave then,
...
Configurations such as this one: https://s-media-cache-ak0.pinimg.com/736x/c4/2f/90/c42f908f046399f8d097a7ecc6cf8bf4.jpg[^] are not that uncommon in the financial industry anymore. And my apps must follow the trend. So I really need a printout of this program. Then I can use the coordinates in my test program to simulate multi- monitor environment and draw it correctly.
|
|
|
|
|
To get the type of information you mention, I think you'll have to use the MonitorInfo API call 'GetMonitorInfo, and examine the state of the 'MONITORINFO or MONITORINFOEX structures it returns: [^].
This may be useful: [^].
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
I want do show my gps cursor in Mapwingis by C#. I want to show red cursor when gps stop and show green cursor when gps is running? I want to do it in C# please help me.
|
|
|
|
|
What exactly have you tried? What code do you have in place already? Do you have GPS capability in your application already? What platform are you going to run this on?
This space for rent
|
|
|
|
|
actually i have got lat and long from Gps by serial port but i want to show gps cursor on my mapwingis. MY program is based on dot net framework.
programming language is C#.
|
|
|
|
|
I was actually asking whether it was WinForms or WPF?
This space for rent
|
|
|
|
|
|
And are you talking about the commercial MapWin GIS from ThinkGeo which has it's own support center[^] which is full of helpful information?
This space for rent
|
|
|
|
|
Hello,
I just want to find out if the tollbaricon or the notifyicon ist clicked. I know how to do that in a own class. My problem is, that I have a while-loop and in this one, I must check if one of the button is klicked. (Because only then the while have to break.)
May you help me? May you have other ideas how i can realize it?
|
|
|
|
|
You can't, without playing some very nasty games with DoEvents.
The problem is that unless you are explicitly threading your app, the while loop is executing on the same thread as the rest of the UI elements - so the click action won't get honoured until after the loop has finished and the event handler that started it has returned control to the system.
It's like a man who is so busy concentrating on what's in front of him while he is driving, that he doesn't notice the fire engine trying to get past!
You can do it, but you have to change the way your application works, and move the loop into a separate thread. You can then set up an "terminate" variable which you check in the loop, and set in the Click event handler. Have a look at the BackgroundWorker Class (System.ComponentModel)[^] - it provides a safe and easy way to do this, but be aware that you cannot access any UI elements except on the same thread they were created on - if you try to do that inside your loop using a BackgroundWorker you will get a "Cross thread exception" and that means you need to use Invoke to move the access back onto the original thread. This isn't a simple subject and it's probably an idea if you do some background reading on Threading first before you get too complicated.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi,
I need to access my gmail contacts to upgrade an Access database. A program in C # manages this basis. I checked on the Internet and appeared several ways, but none worked. I found a video that the speaker creates the code step by step and in the end he managed to access the gmail contacts.
I typed the code and is giving an error in word in of code:
foreach (Contact contato in f.Entries)
The following code:
using System;
using System.Data;
using Google.Contacts;
using Google.GData.Client;
using Google.GData.Extensions;
namespace ContatosGmail
{
public partial class Default : System.Web.UI.Page
{
protected void btnObter_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.Tables.Add("GmailContacts");
ds.Tables[0].Columns.Add("EmailId");
RequestSettings rs = new RequestSettings("Taveira", txtUsername.Text, txtPassword.Text);
rs.AutoPaging = true;
ContactsRequest cr = new ContactsRequest(rs);
Feed<Contact> f = cr.GetContacts();
foreach (Contact contato in f.Entries)
{
foreach (EMail email in contato.Emails)
{
DataRow row = ds.Tables[0].NewRow();
row["EmailId"] = email.Address.ToString();
ds.Tables[0].Rows.Add(row);
}
}
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
lblStatus.Text = "Toal de contatos para " + txtUsername.Text + ": " + ds.Tables[0].Rows.Count.ToString();
}
}
}
I am in urgent need of this solution.
Using Visual Studio Professional 15 and Windows 10.
Thank you.
|
|
|
|
|
Most likely no one here is going to debug this code for you, or provide you with a "fixed" version.
It is your task to analyze the code, single-step through it and observe the specific error(s). Then, ask specific questions here, giving a clear description of the error message(s). And, unless you understand the code, how will you maintain it in the future when Google changes their API's, or some change in whatever occurs ?
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
check for "Contact" . It should be in blue color. Try to navigate.
|
|
|
|
|
When you get an error in your code and post a question about it, it would be helpful if you actually said what the error was. I'm going to go out on a limb and suggest that the exception you see on your first foreach line is that you have an "Object reference not set to an instance of an object" exception. You will see this if the call that is responsible for creating the object (i.e., your call to GetContacts) returns a null value. To be honest, this sounds to me like your RequestSettings are inaccurate or you have something like a Firewall preventing you accessing Google from your app.
I will add that we consider it rude to put "urgent" in a question. It's only urgent for you; you aren't paying us anything for our time and we're all volunteers so it's at our discretion when we answer your question.
This space for rent
|
|
|
|
|
Thanks a lot for the help.
|
|
|
|
|
Been hearing a lot of people having trouble with icons, I decided to updated my article I wrote back in 2004 Access multiple icons in a single icon file[^] with a long needed update.
New version of the library lets you import pictures and create 32bit icons with multiple sizes of the image. Hopefully, this can help people who are having troubles with icons with this replacement for the icon class.
Grab the library and sample app:
GitHub - hazlema/MultiIcon: Display or Convert 32bit icons.[^]
Written in C#, Community 2015
Matthew Hazlett
Fighting the good fight for web usability.
modified 14-Jun-16 19:29pm.
|
|
|
|
|
This forum is for asking questions about, or having technical discussions about, C#.
It's not the place to promote your article. That's the job of the various newsletters, RSS feeds, Twitter feeds, Google+ feeds, and "updated article" lists.
I suggest you remove your message, before trigger-happy members start reporting it as spam.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You might consider posting this on the Lounge; you are, after all, talking about a revised code provided for an article here on CP. There are lots of posts on the Lounge where members talk about their achievements, challenges, current work; quite often these posts do not refer to specific CodeProject resources, or discussions.
However, it appears that the only update (I can see) of the article is that you simply added a message in the comments section announcing it, and linking to the project on GitHub. Unfortunately, it is also correct that some people seem to have have a certain latitude for Lounge post content that others do not (welcome to "human nature"); reaction to your post ? ... who knows ?
It appears to me your code is now in C#, rather than VB.NET; I suggest you edit the article, and at least mention that.
Since, I assume, your new code reflects some new/different ideas, or techniques, compared to a year, or more, ago, one can hope you might revise the article.
You also might notify CP staff of the revision; frequently the e-mail updates from CP members subscribe to include mentions/links to revised articles. I suggest you wait to do that until after you have revised the article text. I am not sure of the exact mechanism for this; perhaps revised articles are selected for mention automatically.
All of this is, of course, imho.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
modified 14-Jun-16 23:40pm.
|
|
|
|
|
I want to create three cars from different directions meeting at the junction
|
|
|
|
|
And how is this relating to C#?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
1) Buy three cars.
2) Get three drivers, and give them each two mobiles.
3) Get them to call each other so they can all hear each other and coordinate activities.
4) Get them to drive at an appropriate speed into the same junction at the same time. I'd recommend videoing the results for YouTube.
(4) May be the hardest part, unless you find really stupid people who don't realize they may well be injured or killed. Alcohol may help here, but would impair coordination as well as being illegal.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|