C#: How to create a window like this? - c#

I need to create a window similar to this:
a window similar to the types of dialog boxes that have been included with windows vista.
but I could not find exactly the same dialog boxes. very similar - it's Credential dialog and Input dialog. In the first case there are differences in the UI, in the second - the number of input fields and the absence of label. How can I make exactly the same window? Sorry for bad English.

You want to create a dialog exactly like the first dialog you've shown, the one used by FluffyApp?
You'll have to create it yourself, by hand. It's not a standard Windows dialog; it's a custom dialog resource provided by the FluffyApp application. It's obviously modeled to look a lot like the standard Windows authentication dialog, which is a good idea—users are already familiar with the native UI and will find your application to be much easier to use if it strongly resembles what they're already accustomed to. I recommend that if you decide to create your own custom dialog that you follow Windows's example as well.
But it's not entirely clear why you need your dialog to look exactly like the one that FluffyApp uses. I'm not really even sure why FluffyApp needed to create a custom dialog! It seems like the standard Windows authentication dialog would be perfectly sufficient. They have the same number of input fields, the UI designers at Microsoft have just replaced labels with cue banners. Not anything to worry about.

Those are standard windows dialogs, but instead of letting the dialog manager draw the text, they use DrawThemeText to draw the text, using one of the themed elements (not sure what, because you have several examples). You can play around with the various parameters to DrawThemeText to come up with something that works.

Related

Get new Messagebox style - WPF

I am currently working on a Windows Presentation Foundation app and I need to make use of Message boxes. I want to get few information from user inside Message Box popup.
But they appear always like this:
But I think the actual look of it should be like that:
Does anybody know, why this is, and how to solve it? I tried all everything listed
here
, but nothing worked.
I agree with Keithernet, build your own. Its more of an Input Dialog box. You may want to plan it to create a window, create it with ex: 4 parameters which you could override so you can apply them in the form including
The title,
The prompt you want the user to fill in
optional default button 1 text
optional default button 2 text.
have the input value stored into a public property in the window for the text to be bound to during entry.
If the user clicks the cancel button (or similar), clear the text entry and close the window. If ok button, just close the window.
Then, when you call it with a YourWindow.ShowDialog(), upon return, you can look at the public property for that input text value.
You could even do with a property / flag if the user cancelled directly or not. I have done similar in a couple of my WPF apps.
MessageBox is very limited. Based on your screenshot, you should just create your own child Window with your own XAML so you can get the user input.
You can find sample service implementations/NuGets for this on GitHub. Here is one I've created sometime ago: https://github.com/Dirkster99/MsgBox
Just create your own is an oversimplifying statement in my opinion because this is usually a dialog that you want to show in different parts of the application. Therefore, you have to settle for a software design pattern (I chose a service implementation as suggested here).
Likewise, there are other design decisions that should be taken. I have for instance made sure that the API has a compatible subset of Show API calls with the standard .Net MessageBox to make its application as flexible as possible. I also settled for light and dark themes hoping this will make its application easy in any other theme...

How can I make a menu-like form stay on the screen, on top of all other apps?

I want to make a menubar like window taskbar in C# but I'm wondering how can I make the form stay on the top of the screen and other program will not taped over it just like the window taskbar and when the mouse hover on a icon it will show a form like this:
I have made it like this:
And This is what I want
Windows has a facility for this, allowing you to basically create pseudo-taskbars that dock to the side of the screen and are always visible. It was used by the Office team (possibly publically documented for the Office team?) a long, long time ago to create a desktop toolbar.
Anyway, they are called Application Desktop Toolbars (or "AppBars"), and the documentation is here. To register one, you call the SHAppBarMessage function with the ABM_NEW message. Complete sample code is available in the linked documentation, unfortunately it is in C++.
To use this from a C# application, you will have to P/Invoke. As far as I know, it is not wrapped by the .NET Framework anywhere, probably because it never gets used by anyone anymore. This CodeProject article appears to have the necessary P/Invoke definitions written out. I can't vouch for their correctness, but armed with the documentation and that as an example, you should be able to cook up a working demo.
There is another CodeProject article here, written by Arik Poznanski as part of a series on using shell features from C#. It looks much more thorough, probably more than you need.
Set the property Form.TopMost unless you have other programs creating topmost windows. Doh!

Is WPF adequate for creating such a form or am I missing something?

Intro:
I am quite new to C#.
It is my job to create a certain simulation program.
I can't ask other programers, I'm an intern with a nonprogramer adviser and should not nother them. (I'm doing more of a fun project.)
So before spending a week or two to get really into WPF, I wanted to make sure it fits my needs.
If not, I want to use something else.
What I need:
Show the user a range of radio buttons to decide wether a simulation/plot/opening_of_svg should be done or not. (Can be done.)
A button "Add Task" where the user can choose one. (Can be done.)
Depending on the choice, add a certain form into the existing one, where parameters can be set. (Not found.)
Some of them radio buttons. (Can be done.)
Some of them text box, for integers and doubles only. (Can be done.)
All of them with default values. (Can be done.)
After adding a task, another "Add Task" button should be created, for adding more of them. (Not found.)
If for example a second simulation is added, it should take the values of the first one as default. (Can be done.)
Save the choices and data to a text file in a certain syntax like "Gnuplot Add Restriction = Time" which is used by the rest of the program. (Can probably be done.)
Question:
The biggest uncertainty is the one with adding forms into the forms.
Can this be done in WPF?
If there is any other framework (if this is the right name) specially made for this, feel free to comment.
I can't add many links due to my reputation. I might do it later. Just in case someone will find this later and wants to know about how.
Rather than creating Forms, consider creating UserControls and arranging them within a single Window. This is the same pattern you might use when creating composite windows in WinForms. I'd recommend the Grid or DockPanel layout panels.
In this respect, WPF is quite similar.
In addition, it sounds to me like you are doing a feasibility study for a new requirement. Are you sure it is not appropriate to speak to more senior staff? If I was them, I'd want to know your findings!
On reflection...
It seems like you are trying to create a branching Wizard workflow, like an installer might give you, i.e. Next, Next, I Agree, Next, Finish. WPF Can absolutely do this and some open source solutions already exist. For example, Avalon Wizard.

How to develop my own .NET controls?

I've been struggling for a long time with basic controls that Windows Forms offers to developers, but... right now, I am developing an application that requires more advanced control than normal "TextBox".
Since, at this time, my application is about memory management, I have to show in the form, the process memory in bytes (or other type of data) to the user, giving it the ability to modify it as he wants.
The problem comes here, because... if I show the data in a TextBox, it only allow me to display the data in read-only text because if I let the user modify the textbox directly, it will be very messy and unaesthetic.
I was reviewing some projects on SourceForge about C# and the handling of hexadecimal data, and i found a good project, called Be.HexEditor, which has a control developed and designed by its creators, but in GDI+.
The control is called HexBox, and that's just what I need to get.
Do any of you know how to develop a control like this?... I would greatly facilitate things. What kind of manuals/books should I read to learn this kind of development? I ask this because I ignore everything about GDI+.
Or... is there other way for do it?
I would use a textbox to show to the user the current value and another textbox to enter the desired value (maybe a slider will work better).
I think you'll find it's GDI+ that you have to learn
http://www.amazon.co.uk/GDI-Programming-Creating-Controls-Programmer/dp/1861006314
You may still be able to write controls in WPF and then include them somehow into your winforms app, but if you need to push pixels GDI+ is the only way.

Creating A New SaveFileDialog

After a lot of thought and consideration, and Google-ing, I'm hell-bent on creating my own SaveFileDialog.
But I do not know where to start and since I haven't seen anything around the web, I would like to know if anybody has done this before, and what I should look into, or how I might go about doing this?
I am wanting to build a new SaveFileDialog because I feel the need (or want) to add more functionality to it. And I also feel that if I build a new one, I'll learn alot more about C# and how the SaveFileDialog works behind the scenes
To be quite honest, I don't like the current SaveFileDialog (Yes, it does the job) but I really do want to add extra functionality to it.
Ah, I don't think that there are any restrictions. I can't say for sure because I'm new to this and don't know what is required or...
Why not extend it instead of creating from scratch?
Well a dialog is just a form. Start with a form, add the file system browsing components (listview, drop downs) etc, add your code behind. Its not that difficult but may be tedious, but I'd say a good educational exercise where the you'll learn why you may want to just use the built in one.
If you are really really sure you want to create your own version of a SaveFileDialog, I'd recommend not just cloning the existing one. If you make it look like the standard one, people will expect it to behave like the standard one, but there's lots of little details and you probably won't get them all.
You want to avoid The Uncanny Valley of User Interface, so you should make it clear that it isn't trying to be the SaveFileDialog + some-new-bits. It should just achieve the same goal (i.e. choosing where to save something).
If you do want to create SaveFileDialog + some-new-bits, then going down the path of extending the dialog as Shoban says is the way to go.
NOTE: None of this really applies if all you want to do is build your own for learning purposes, and then throw it away when you're doing. But if you ever want to use it a real project, then you should keep this in mind.
The SaveFileDialog is part of the operating system and will actually look different on different versions of the OS. There are a lot of ways to customize it, but that is not so easy in a Windows Forms project. It can still be done, but you have to hook into the native Win32 API. If you simply want to play around with Windows Forms and C# you can go ahead and design a form that looks like a SaveFileDialog but you will miss all the goodness of the native dialog.
You can read more about the common open and save as dialog boxes on MSDN, but if you are used to Windows Forms programming you may feel alienated by the native Win32 API. Window Vista has introduced a new common item dialog and the COM based API makes it easier to use in a Windows Forms application.

Categories

Resources