I'm calling my custom dialog window with this code:
GUI.SLDialog sd = new GUI.SLDialog();
if (sd.ShowDialog() == false)
{
return;
}
But sd.ShowDialog() always returns nothing (i think), because the function breaks, but the waypoint at return; isn't reached.
Dialog is automaticly closing when I add to button:
this.DialogResult = false;//or true
Anybody know what am I doing wrong?
Thanks in advance for your help.C.H.
#edit
This is my SLDialog:
xaml: http://wklej.org/hash/9fb67fb0c7c/
cs: http://wklej.org/hash/16e3ccc6c0d/
I don't think I can tell you much here unless you post the code for the dialog but I do have a suggestion in the mean time.
Since you're already unhappy with the standard dialog boxes and customization is clearly an option why not move towards what people are coming to expect? Instead of your standard dialog why not just create a user control that lays over the rest of your UI and blurs everything out from the background? Much like a jquery dialog box you might see on a web page.
Modality is easier to control since it's just a matter of covering your entire app window with a translucent rectangle and then make the dialog window appear however you want.
Just a suggestion.
Related
I have a populated ListView dialog. If a user clicks on an option in the ListView, a new dialog is shown above the ListView.
My problems is that when I click off of the new top-most dialog (onto the ListView behind it), the new dialog's borders flash/blink several times. The icon on the taskbar also flashes. I wish to disable the flashing, but cannot find a property to change.
To show my dialog, I use the following code:
if (detail == null)
detail = new Details(opt, val, user, desc, m_l);
else
detail = null;
detail.ShowDialog();
This is intended behavior, it's because the new dialog is modal. It's drawing attention to the fact that something needs to be done.
If you need to make a non-modal form, instead of using ShowDialog(), simply use Show().
Sounds like to me you are creating modal windows each time. And you cannot resume the previous dialogs until you dismiss your new top-most window.
Take a look at this wikipedia article for information about modal dialogs.
I would advise you look at how you are creating/showing your windows.
In WPF you show windows via Show() or ShowDialog(), however, I do not know which type of ListView you are using
EDIT:
Per your comment, you want modal dialogs. The only ways I can think of even trying to remove the flashing is going into WINAPI. This doesn't seem like a job for .NET.
I want to suggest a few things:
Take a look at options for showing each window. See this MSDN page
Take a look at the options for styling each window. See this MSDN page
Reconsider your design. I know this may take a lot of work, but having so many layers of windows is kind of unappealing to most users. Ultimately, I believe this option will make your application the best.
Thank you all for your answers and guidance. I have found the best way to handle my problem.
I was using an event ItemActivated. This event was called when an a highlighted item on the ListView was clicked. This became a problem when the user would double click on an already selected item. This would cause the new dialog to show, but also flash several times.
By using the DoubleClick event instead, a single click on a selected object does nothing. A double click on either a selected or non-selected item opens the dialog without the flashes. The flashes still appear if you try to click off of the dialog box, but are not as much of an issue.
I'm trying to write a program with C# that sends text into other windows.
How do I write a command in C# that sends a text into the window that is currently under the users focus?
For example:
If the user clicks an open notepad window, or an open outlook letter, or an open excel sheet, and then clicks the button on my program, a text will be "pasted" directly into the last notepad window/outlook letter/excel cell that the user clicked on last.
I hope my question is clear enough. I'm not so experienced and am missing a lot of terminology.
Take your application out of focus by minimizing or hiding the main window, and then send your text with
SendKeys.SendWait("Hello World!");
Finally, restore your main window.
If the code is executed in the main form, you could do this
this.Visible = false;
SendKeys.SendWait("Hello World!");
this.Visible = true;
Olivier's response actually seems more accurate (and taught me something :)) than my original "does not seem achievable". If you need an example, then take a look at this:
http://www.codeproject.com/Articles/18366/Sending-Keystrokes-to-another-Application-in-C
However, on a more complex level, without an API to call into, there is not much more that you can do beyond this solution.
I'm tired and hungry, so I might of missed it, but from what I can see no existing post covers this...
I'm writing a plugin for an application. My plugin loads a form to get some data specifically, it uses the webcam to scan for a barcode. Once it's found a barcode, the form hides itself (incase it's needed again later). This is how I currently call the form that does the barcode work:
string readData = null;
if (eye == null)
{
System.Windows.Forms.Application.EnableVisualStyles();
eye = new CamView();
}
eye.Show();
if (eye.found)
{
readData = eye.readData;
}
return readData;
So, my problem is that eye.show() doesn't block. It makes the form appear and carries right on before there's a chance for the barcode to appear. I imagine I need to use some form of threading or locking, but my crude attempts to do so have just frozen the interface completely.
The "eye" form is basically just a viewfinder for the webcam, and relies on the camera_OnImageCapture event to make it do it's image checks for the barcode.
Is there an elegant way to make the application calling the plugin wait for the form to finish? Or do I just need to add an accept button to the "eye form?"
Cheers. And humble apologies if this is in anyway a repost.
.ShowDialog();
http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx
"You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed."
You are on the right track. You change the code to show CamView as a modal dialog but do no add an Accept button. Instead change camera_OnImageCapture to close the dialog.
I have an application that brings up a popup window when you click a link. I have a watin test that naviates to the page and clicks a link to open the popup. This is my current code:
[Test]
public void TestCommentBoxInput()
{
window.GoTo("mylocalurl");
window.Link(Find.ById("popuplink.aspx")).Click();
IE iepopup_1 = IE.AttachTo<IE>(Find.ByUrl("popuplinkurl.aspx"));
iepopup_1.TextField(Find.ById("txtComments")).TypeText("Commenttest");
}
As you can see I tried attatching the popup window to the created browser called window. When I run my test it just stops at the popup window and never enters text in the box. How do I go about making my program regonize that it is now to be operating on the popup and not the original window?
EDIT: I am dealing with a Modal Dialog.
I think the Find.ByUrl try to do a exact match, try with a Find.ByUrl(u => u.Contains("popuplinkurl.aspx"))
So I have figured out the problem, the problem was I was using a Modal dialog and they are handled differently. My new code is as follows in case anyone is stuck in the same position I was in. :)
public void TestCommentBox()
{
window.GoTo("mylocalurl");
window.Link(Find.ById("popuplink.aspx")).ClickNoWait();
HtmlDialog dialog = window.HtmlDialog(Find.ByTitle("TestPopup"));
dialog.TextField(Find.ById("Txtcomments")).TypeText("Commmenttest!");
}
The important lines are:
window.Link(Find.ById("popuplink.aspx")).ClickNoWait();
Notice that I am using ClickNoWait() and not just Click, I am unsure as to why this makes the difference, but it does! If someone could explain that that would be great.
HtmlDialog dialog = window.HtmlDialog(Find.ByTitle("TestPopup"));
Because I am dealing with a Modal dialog you have to declare a new HtmlDialog. Also in order to use Html dialog make sure you include Watin.Core.DialogHandlers. I hope this is helpful to someone out there! :)
How can I create a Popup balloon like you would see from Windows Messenger or AVG or Norton or whomever?
I want it to show the information, and then slide away after a few seconds.
Edit: It needs to be blocking like Form.ShowDialog() because the program exits after displaying the notification
You can use the notifyIcon control that's part of .NET 2.0 System.Windows.Forms. That allows you to place an icon for your application in the System Tray. Then, you can call the ShowBalloonTip(int timeOut) method on that. Be sure however to first set the text, and icon properties on the notifyIcon for it to work. Small code sample:
private void button1_Click(object sender, EventArgs e)
{
this.notifyIcon1.BalloonTipText = "Whatever";
this.notifyIcon1.BalloonTipTitle = "Title";
this.notifyIcon1.Icon = new Icon("icon.ico");
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(3);
}
EDIT: Ok, so notifyIcon won't work for you. My second suggestion would then be to create your own control for this. Actually, I would use a form. A simple form, with no borders, and no control box and just have a timer running so you can set the Opacity for fade in/out. Then, you can easily get the bottom right of the screen using the Rectangle Screen.PrimaryScreen.WorkingArea. Then just show your form at that position.
Don't create a modal (blocking) balloon. Please. A big part of the design of these UIs is that they are not dialogs: they're transient, potentially non-interactive elements, intended to provide incidental information to a user without necessarily interrupting their workflow. A balloon that steals focus and blocks user input would be irritating at best - if you need a dialog, then use a dialog.
The .NET 1.1 Visual Basic Power Pack had a toaster control.