Screenshots
Videos
Comments
Excellent work. The GUI feels really good.
Awesome stuff! I was using Windows Forms with XNA, but it was really clunky and involved a lot of copying and pasting every time something was changed.
I tried running this on my laptop (Radeon 9000 Integrated) but it didn't run (Invalid Method Call), I tried fiddling around with the code and found that it ran if I changed the numberLevels to 1, and switched the SurfaceFormat from Vector4 to Color (Rgba32) it worked. Great work, keep it up!
Thanks F286! I will make the necessary changes.
The update will also have 3 new controls : text button, scrollbar (vertical and horizontal) and menu. The scrollbar will also be added to the listbox and listview.
I'm having trouble getting the source code to run. I get an 'InvalidOperationException' was unhandled in line 60 of slider.cs when I try to run it in Visual Studio C# Express. Please tell me you know how to fix it! BTW love the video of it when it works!
Any help would be much appreciated.
This is the same problem that F286 made me aware of concerning video cards that can't create a texture from vectors and colors have to be used instead. The next version will be uploaded very shortly (today) and this problem will be fixed.
Thanks for the update to V1.1. It now works on my machine (Ati x1650Pro PCIX16 512MB SM3.0). Now I can start to play with it. Being a newbie I'm probably way off when I describe the following bug: When you close a window and then reopen it through the File->Open menu and you do this to all windows the inter-window/form callbacks are not re-hooked. They do not dynamically update anymore. Excellent work, thank you - you've already saved me months of work in realizing my own ambitions :).
Excellent! This keeps getting better and better.
headkase, thats because the new loaded form did not have any event initialized. Maybe I shouldn't remove them automatically from the collection after they disappear.. I'll try to figure something out, thanks!
Thank you Derek :)
The next update will include xml serialization and some fixes.
I forgot to mention, right now only one submenu level will be loaded through xml files. That will also be fixed in the next update.
Is the current theme hardcoded into the program somehow? Changing the references in the code does not appear to work. I have replaced images in the Default theme's directory with some nice widget graphics I borrowed from a WindowBlinds Vista theme and that works. A suggestion as well, on the open and close events for a form an expanding from center while fading in and a shrink to center while fading out respectfully would be very nice.
If you add your theme folder to the style enumeration and use it when loading the form, it should be using your theme files, like Form1 is currently set to.
I'll see about adding the "popping in/out" effect.
butterfly(V1.1): when a form is maximized to full screen it's title bar is underneath the menu bar at the top of the screen.
Do you have a bug tracker going?
Combo-box does not allow the current item to be selected from the drop-down list. This is either correct or not depending on how you look at it: It shouldn't change; the user clicks the drop arrow to close the list and retain the selection if thats what they wanted - or: It should select and close the drop-down even if it is already the current selection to facilitate ease-of-use for the user as they interact with the GUI.
But hey its yours to make work the way you want, I'm just happy you've shared it with all of us.
although it still needs some work, you can report bugs here :
http://bugindexer.webhop.net/ (if the top or bottom doesnt load correctly, reload the page)
(either sign up and wait for me to validate you or use xwin/form as the username and password respectively)
Forms that are marked as not re-sizable do not disable the forms maximize widget. Checkboxes are right in that they are inclusive (You can have as many on as you want) however radio buttons are meant to be represented within groups that are mutually exclusive to their respective elements (Of three radio buttons in a group (with possibly many groups on a form) only one may be true; the others are always set to false whenever a new radio button within the group is set to true).
What am I doing wrong with this XML form definition:
Input Dialog
{X:10 Y:30}
{X:500 Y:205}
{R:154 G:205 B:50 A:255}
{R:0 G:0 B:0 A:255}
100
True
True
13
3
Label
label1
{X:12 Y:82}
Enter name for State:
{R:255 G:255 B:255 A:255}
100
Textbox
textbox1
{X:65 Y:80}
120
False
Default
TextButton
Add
{X:12 Y:260}
Add
180
{R:255 G:255 B:255 A:255}
(I added the codes just in case). The XML parser chokes when it gets to converting the form_position tag and I don't know why. Any help would be much appreciated.
Dammit the server ate the xml tags.
It hangs on the form_position element which has a value of {X:10 Y:30}
headkase, use the bug report or send me a message please.. This is mostly a comment area, not a place to have long conversations.. thank you.
psycadelik: Ok, sorry. Eventually found the difficulty: had to specify the full path for the xml file as in: forms.LoadForm("K:\\Projects\\xWinForms\\Samples\\mainmenu.xml");, instead of: forms.LoadForm(@"samples\\mainmenu.xml");.
Cheers mate, and thanks for the code again.
Thanks for another great project!
Why not support Unicode text? and how to support?
MyWisest: The new version (1.2) that willl be released today will include the use of SpriteFonts. Sorry I forgot to mention that.
Can you add a text attribute in these controls?
include menu,buttons,label,checkbox,radiobutton controls etc.
Every controla have text and name attribute,use text attribute for render,use name attribute for code.
Controls that can display text (excluding menus) are using the text attribute to display it and all controls are using a name attribute. If you need a button with text, try TextButton (yea I know I should merge that with the original Button class.. next update)
what time for next update?
Can you release a DLL?
This week for sure and I'll see if I can make a dll out of it. Thanks for suggesting it.
Have a advice,replace Games1 name with ServiceHelper in any control's code.
public class ServiceHelper
{
private static GraphicsDevice _graphics;
public static GraphicsDevice Graphics
{
get { return _graphics; }
}
private static ContentManager _content;
public static ContentManager Content
{
get { return _content; }
}
private static Game game;
public static Game Game
{
set { game = value; }
get { return game; }
}
private static HUD hud;
public static HUD HUD
{
get { return hud; }
set { hud = value; }
}
public static void Initialize(GraphicsDevice g, ContentManager c)
{
_graphics = g;
_content = c;
}
public static void Initialize(Game game, GraphicsDevice g, ContentManager c)
{
_graphics = g;
_content = c;
Game = game;
}
}
in Game1's method add:
ServiceHelper.Initialize(this, graphics.GraphicsDevice, content);
ServiceHelper.HUD = hud;
Thanks MyWisest, although the Game and HUD classes have been removed from the library dll. But I managed to get everything in working order. The release will be available today. Sorry for the small delay.
I suppose that all 3D rendering should be done before the forms are to be rendered. Are all the renderstates set correctly after the forms have been rendered or do we have do handle that ourselves?
...and, will it be ported over to XNA 2?
That's right and you'll have to handle the renderstates yourself for now. I'll fix that in the next release, which will be for xna 2.0. I might keep a version updated for xna 1.0 refresh as well, if someone needs me to.
I do have a problem myself (Version 1.3). I created a form and wanted to include an Event Handler on my Combo Box so that the selection would appear in a given text box. But this does not work with my own form. In the examples of Version 1.3 this works. I don't get the mistake as I did it the same way.
Guntpat, If you are talking about the new version (for XNA 2.0), I just made some tests and and everything seems to be working fine.
[code]
combo = new Combo("combo1", new Vector2(10f, 40f), 100, forms["Test Form"].font, Form.Style.Default);
combo.AddItem("item1");
combo.AddItem("item2");
combo.OnChangeSelection += new EventHandler(combo_OnChangeSelection);
forms["Test Form"].Add(combo);
private void combo_OnChangeSelection(Object obj, EventArgs e)
{
Console.WriteLine("Combo changed to : " + combo.selectedItem);
}
[/code]
Thank you! Surprisingly it seems to work now, but I have another problem. I created a form where the user is able to create players (i.e. he can choose between numerous of colors for his avatar). Now I want to verify that he doesn't choose a color twice. I want a Message Box (which contains an error message like: "You have chosen a color twice!") to appear when the user presses a button.
[code]
//in the program
startButton.OnPress += new EventHandler(button_onPress);
private void butto_onPress(object obj, EventArgs e)
{
forms.Add(new MessageBox(forms["form1].font, "You...!"));
forms[1].Show();
}
With this code, the Message Box appears, but behind form1. What can I do to realize a modal and "inFront"-MessageBox?
What is form[1].Show() for? The message box? Because form[1] doesn't necessarily refer to the message box but to the first form in the formCollection which is probably your avatar form.. Show should be called from the message box class anyway. So if it's for the msgbox remove it, if not, I would think just inverting Add() and Show() would do the trick..
I hope this helps and if you have other personal questions you should email or pm me instead.
forgot to mention, in form.cs, there's a very useful function called SetFocus(). It might help too..
Wow i love xWinForms!
Will there be ImageBoxes in near future??
It would be very helpful.
Thanks Apprauuuu. Adding an imageBox control should not be a problem, I will add it to the list. Thank you for suggesting it.
Hi psycadelik. I've noticed that the Textbox control has a bit of an anomaly to it. If I type in some text, and then hit the left arrow key to move my cursor back to the beginning of the text, and then hit my right arrow key to move the cursor to the end of the text, the cursor stays in place while the text sort of scrolls by, so by the time my cursor is back to the end of the line, I can only see one character. This seems to be tied to actually holding the right arrow key down. If I just hit the arrow key one at a time, it still does it, but not as much. I hope that makes sense...
You could just use Home/End :p But I'll fix it in the next update which I'm not sure when will be ready exactly.. I'm sorry for those patiently waiting for it.
Thanks. One question: Is there a way to set the color of a portion of text in a text box? Like a highlight color for just a word or a line or something.
Also, I've noticed that the z-order of the forms seems to get messed up when I click on the title bar of a form with another form underneath. I'd expect to get the form that I'm clicking on, but it always brings the bottom form to the top, which seems strange.
Thanks for a great library, though. It's very useful so far.
Tom
I would suggest that...
private Button closeButton, minimizeButton, maximizeButton, restoreDownButton;
...in Form.cs be changed to public, so the application can add event handlers to them.
I've made a handful of improvements to this library, like fixing the multiline wrapping code and some other things. Is there some way I can contribute my modifications to the project?
Hey bOjangles, I suppose you were able to answer your questions, sorry it took me a week to reply. Of course you can contribute to the project, email me your code at psycadelik@yahoo.com and let me know which classes were modified and ill incorporate those in the next release.
Sorry I haven't emailed you. Been busy. Somebody just asked me for my code, so I thought I'd post it here. I forget exactly which classes I've modified, but most of my changes were in Form.cs and Textbox.cs. You can run diff on the files to see what I've changed. Anyway, you can download my modified code here:
http://www.gersic.com/files/xWinFormsLib2_0.zip
There aren't any groundbreaking changes, but I've fixed the wrapping code so it wraps at word breaks, and fixed some form bugs.
You can see it in use at:
http://hotlidsallsizes.com
Tom
From what I can tell from b0jangles' project, while some very cool features have been added, the multi-line textbox bug still exists (i.e. you cannot edit text when multiple lines are enabled). Has anybody found a workaround for this?
Multiline seems to have just been disabled because of bugs. I don't know which bugs those may have been...maybe I've already fixed them ;-)
In Textbox.cs, just change this:
bLocked = true;
To this:
bLocked = false;
That makes it editable, but Keys.Enter doesn't trigger a newline. If you go down to line 503, you'll see this has been commented out:
else if (currentKey == Keys.Enter && bMultiline)
Add("\n");
Just uncomment it.
There's no cursor, but otherwise it seems to work reasonably well. Lines don't seem to wrap when you're typing, but that should be relatively easy to include.
Also, I remembered a few other things I added. I added a Picture.cs to display images on the form. I also added some public event handlers, like a keypress handler on the text boxes, so you can have, like, Keys.Enter trigger something in your program. For instance, I have Keys.Enter submitting a chat message. And I added a bCanClose parameter to the Form constructor because I was having some problems with clickthrough.
I have written a new textbutton that inherits from button,
is useful to use textbutton with buttongroups.
Code
-----
public class myTextButton : Button
{
static int indice = 1;
private SpriteFont font;
private Vector2 textPosition;
private Vector2 textSize;
public myTextButton(string text, Vector2 posicion, SpriteFont font)
: base("boton" + indice++, "button", posicion, Color.White, Form.Style.Default)
{
this.text = text;
this.font = font;
textSize = font.MeasureString(text);
size.X = textSize.X + 10 > size.X ? (int)textSize.X + 10 : (int)size.X;
size.Y = textSize.Y + 4 > size.Y ? (int)textSize.Y + 4 : (int)size.Y;
textPosition = new Vector2((size.X - textSize.X) / 2, (size.Y - textSize.Y) / 2);
}
public override void Draw(SpriteBatch spriteBatch, float alpha)
{
base.Draw(spriteBatch, alpha);
Color dynamicTextColor = new Color(new Vector4(0f, 0f, 0f, alpha));
spriteBatch.DrawString(font, text, Vector2.Add(position,textPosition), dynamicTextColor);
}
}
sorry, but i do not speak English.
I like this project, but not with a focus on the button when pressing enter in inputtext.
another, also would like to enter in mensagembox and the button is pressed.
have a bug in backspace in the textbox. the correct code:
private void Add(string text)
{
if (!multiline)
{
if (base.Text.Length >= text.Length && text != "")
base.Text = base.Text.Insert(cursorLocation.X, text);
else
base.Text = base.Text.Insert(0, text);
//cursorLocation.X += text.Length;
}...
You have a bug in the Render Form:
What has more than one combobox, only the latter works. To resolve you should change the lines:
int overlay = 0;
for (int i = 0; i < controls.Count; i++)
{
if (controls[i].GetType() == typeof(ComboBox))
{
overlay = i;
}
if (!controls[i].IsDisposed && controls[i].Enabled)
controls[i].Draw(spriteBatch);
}
if (overlay != 0)
{
ComboBox combobox = ((ComboBox)controls[overlay]);
if(combobox.Opened)
combobox.DrawOverlay(spriteBatch);
}
to:
for (int i = 0; i < controls.Count; i++)
{
if (controls[i].GetType() == typeof(ComboBox))
{
ComboBox combobox = ((ComboBox)controls[i]);
if (combobox.Opened)
combobox.DrawOverlay(spriteBatch);
}
if (!controls[i].IsDisposed && controls[i].Enabled)
controls[i].Draw(spriteBatch);
}
I enjoyed some of your code and created a scrollbox. if you want, I move the code.
sorry but my combobox cod have a bug. The correct is:
int overlay = 0;
for (int i = 0; i < controls.Count; i++)
{
if (controls[i].GetType() == typeof(ComboBox))
{
if (((ComboBox)controls[i]).Opened)
overlay = i;
}
if (!controls[i].IsDisposed && controls[i].Enabled)
controls[i].Draw(spriteBatch);
}
if (overlay != 0)
{
ComboBox combobox = ((ComboBox)controls[overlay]);
combobox.DrawOverlay(spriteBatch);
}
Another improvement I made in the combobox is when it is in final form. your listbox is invizivel. With this update, the box is raised above. for this, just change the method combobox inicialize. change the lines:
listbox = new Listbox("combolist", Position + new Vector2(0, 19), (int)Width, 8 * Font.LineSpacing, items);
to:
if ((Position.Y + 19 + 8 * Font.LineSpacing)
if ((Position.Y + 19 + 8 * Font.LineSpacing) \
sorry but the more signal does not work on this site.
the code is:
if ((Position.Y + 19 + 8 * Font.LineSpacing) MORE= heightPai)
listbox = new Listbox("combolist", Position + new Vector2(0, 19), (int)Width, 8 * Font.LineSpacing, items);
else
listbox = new Listbox("combolist", Position - new Vector2(0, 8 * Font.LineSpacing), (int)Width, 8 * Font.LineSpacing, items);
heightPai must be passed by parameter in method combobox create
Hey, this is very cool. But could you add a popup menu? It's quite the same as the regular menu, the only difference is that it shows as a popup in the form. Also adding separators as menu items and the possibility to check/uncheck menu items would be a good idea.
Very Good~ Thanks for your sharing~
Please
log in to leave a comment