Is there an easy way (or perhaps a third-party implementation) to programmatically create a MessageBox with various types of controls on it? Ideally, with some sort of scripting language (ie. XML).
I would prefer not to code this myself from scratch.
There are two ways to do this. One is called WinForms, the other WPF. The latter even uses an XML language (called XAML). Since you didn’t specify what kinds of controls you need, this is the best answer I can offer to your question because it covers the widest available range of controls.
Could you not create a form and customise it as a compromise?
I had a similar question.
Custom MessageBoxes are much simpler to create than what I thought.
How to create a custom MessageBox
Related
I'm trying to get up to speed with C# after years of writing VB code.
I'm trying to add new events in my code. In VB the list of available events is easily accessible but that's not the case in C# and I don't understand the reason for the difference.
I've looked in several books trying to find an explanation for this to no avail.
Can someone please tell me the reason for the difference and/or is there an easy way to add new events to my C# code?
In VB the list of available events is easily accessible but that's not the case in C# and I don't understand the reason for the difference.
Yes, this is a very well known difference between the two languages, which makes working with events much easier in VB than C#.
Can someone please tell me the reason for the difference and/or is there an easy way to add new events to my C# code?
There is no logical reason except that the two languages are done by two different teams who didn't really communicate much and made different decisions. VB has been always making things as easy as possible and doable in GUI. C# on the other hand, targeted more experienced developers who usually favored typing and shortcuts over using GUI.
If you prefer GUI over typing, the easiest way to do it in C# is to select the form or control, open its properties, switch to the list of events, and then double click on the event that you want. This will automatically switch to the code and insert the event boilerplate for you similar to VB.
For the default events (e.g. OnClick), you can simply double click on the form or control in the design mode which will do the above.
Alternatively, switch your Design view to Source view, go to the form or control tag and type the event that you want, it will automatically add ="" for you. Click between the double-quotes, and select the default event name and it will do the above.
We currently have a basic implementation of configurable UI, but we feel like it's not the best way. We are developing another application that needs to be configurable from external file and we were wondering if there is a better way to do it.
We currently have xml file with elements with the name and availability which is directly translated to visibility. When the element is available="false" we hide the element with visibility="collapsed". Elements are enclosed in a Setup element with name. There is separate configuration file with setup name that we want to load.
<Setup name="All">
<Element name="toolBarDrawingTools" available="true"/>
...
</setup>
<Setup name="Operator">
<Element name="toolBarDrawingTools" available="false"/>
...
</setup>
It works reasonably well, but we feel like it's not a great approach just to hide elements. A better approach might be to create and add only elements that we need. Layout should not be much of a problem because most element would be ToolBars, MenuItems or UserControls that would be added to StackPanels. So there is no complicated element positioning. What we also found is define xml files with XAML code and at run-time convert it to visual elements. We do not need that much complexity. We have a set of UserControls that we want to dynamically add.
We do not have a clear vision what we want. In the end, we could use our current approach and it would work. What we need is to define what elements will be in final window from external source without the need to recompile whole application.
So what I am asking is what options do we have, are there any "standardized" ways or frameworks. Do you know any articles or books on this topic? Or should we stick with the simplest approach and just hide what we don't want?
Thank you
As I can understand you are after a modular application development. So I can suggest you to look at the next topics; Modular Application Development Using Prism in internet. For example, by this approach you can use the PRISM discovery mechanism(which uses the app.config file to define modules) in oreder to build whole user interface. Here are a couple of possible links:
Building an Extensible Application with MEF, WPF, and MVVM.
Modular Application Development Using Prism Library 5.0 for WPF.
A MEF explanation topic.
Let me know in case you will need more explanations.
Best regards.
I am beginning preliminary design for a general purpose application to be used in my organization. The program needs to be both generic and specialized at the same time. It will contain widgets that are common to all workflows and unique widgets (or input constraints) for individual workflows. To avoid having 97 different one-offs we're planning on building a set of schemas for each workflow. At run-time the user will select their schema from the server and the GUI will throw up the right widgets for their workflow.
This is a C# application that will run in .Net and possibly Mono. That means we are looking into GTK#, in addition to XAML and MonoMac.
We've considered writing XSLT's for our target GUI toolkit. For example:
A Glade XSLT to convert our XSD's to libglade XML.
A XAML XSLT to convert our XSD's to XAML.
A generic XML format for other toolkits that do not support a declarative syntax for GUI's.
A library of classes to read the XSD's directly and generate the GUI.
So, my question is, does this already exist? Is there some workflow toolkit out there for GTK# and libglade or WPF and XAML.
Look at System.Windows.DataTemplate which can be used automaticly by WPF (see property DataType). I think you can extract all UI blocks, which will be used to generate UI and then implement ViewModels and appropriate DataTemplates. And result UI will be composite view model of this blocks.
I did the same thing using XML. What I'm doing is writing down the property set of each controls into a XML file and then reading from it later and regenerating the window.
Some problems I met while doing so
But I was able to complete it. Anyway I guess WPF is better. But if you want an idea I guess I just gave you. (Might not be the best idea though)
Good Luck
Is there anyway to let users write their own aspx templates with my defined dynamic variables? Note that I don't want to use Web Forms (so there are no tags like <asp:button> etc).
In addition, I'd need a security solution so users can't change the system or do dangerous things like this.
Thanks.
Personally I would avoid using the ASPX engine for this. I would probably use either a really simple custom formatting solution (such as just a text file with %%VAR_NAME%% allowed for dynamic values), or I would look at a templating language such as Markdown (used by StackOverflow and others). BBCode is another option in a similar vein.
Allowing people to create ASPX templated pages on the fly seems like to much of a security issue to me. It would be hard to make sure you have closed all the possible attack vectors once they have direct access to the ASP.NET engine.
Since you didn't specify, I'm just guessing at your needs, so depending on the exact problem this may or may not be your best bet. If you include more details about the problem you are solving it would be easier to make suggestions.
Ok, so is it better to create my own components (Either inherit them from existing ones or creating them from scratch) or to use the ones that come by default?
I'm asking this under the umbrella of scalability, overhead and other factors that my contribute on each of the choices.
UPDATE: Sorry if I'm to vague. I don't really know how to explain myself better. Isn't it a good idea to inherit each default component? For example what if I'm to design a rather large application and for example i need to change the display format on a DateTimePicker. Wouldn't it better to think ahead and inherit it and use the inherited component instead of the defaults?
But, wouldn't it add a lot of overhead in small applications?
This is a difficult question to answer, and may get closed as subjective. It depends on what you are doing, and whether the supportability of scaling it over an existing component is less than that of wrapping a whole new component (inherited or not) and all the entailing support work.
For instance, suppose we have a textbox where we always want to have the text be green. We could just set the font property for the textbox and be done, that would be simple and straight forward, and not need a custom component. However, what if we wanted it to always be green, not be changeable and be enforced regardless of what might be put into the textbox? That would require more code and a certain amount of design work in the app, or we could create a custom component to do this work for us, and have it appear as a textbox to everyone who implements it. Simplifying the deployed code in essence (by hiding it inside the control) and making the overall design cleaner. If we only need this textbox in one place, it is probably overkill, however if this textbox is pivotal to our app it might be worth the time.
I don't think your question has a certain answer - it depends on the functionality that you need. If standard components fulfill your needs then I don't think creation of your own components makes sense.