Hello. I am trying to make some kind of visualStules picker.. here is piece of my code so You can understand what am I doing..
on form load event..
foreach (object stil in Enum.GetValues(typeof(System.Windows.Forms.VisualStyles.VisualStyleState)))
{
comboBox1.Items.Add(stil);
}
than on comboBox1_indexChanged evenent..
Application.VisualStyleState = (System.Windows.Forms.VisualStyles.VisualStyleState)comboBox1.SelectedItem;
that works fine.. but now i want user to see example of the results not to change tne VisualStyle state..
and the example to be drawn in picture box or something.. some form with selected styleState to be drawn and in ComboBox_IndexChange that image, or graphics change.. and finaly if the user like that choise and want to set that style in the application, confirm with dialog.. on button click.. but that is not problem.. the problem is the drawing example..
I want the Example to be something like in the (appairance tab) of Display Properties in WinXp
I was trying something like:
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
Form2 frm = new Form2();
frm.DrawToBitmap(bmp, new Rectangle(new Point(0,0), frm.Size));
frm.button1.DrawToBitmap(bmp, new Rectangle(frm.button1.Location, frm.button1.Size));
frm.textBox1.DrawToBitmap(bmp, new Rectangle(frm.textBox1.Location, frm.textBox1.Size));
frm.label1.DrawToBitmap(bmp, new Rectangle(frm.label1.Location, frm.label1.Size));
frm.comboBox1.DrawToBitmap(bmp, new Rectangle(frm.comboBox1.Location, frm.comboBox1.Size));
frm.checkBox1.DrawToBitmap(bmp, new Rectangle(frm.checkBox1.Location, frm.checkBox1.Size));
frm.radioButton1.DrawToBitmap(bmp, new Rectangle(frm.radioButton1.Location, frm.radioButton1.Size));
pictureBox1.Image = bmp;
but i don't like the results at all..
thank You, and I hope that somebody will help me solve this.. (Ideas or some code are welcome.. )
Loading

jingeRank #2,527 · 554 reputationPosted Oct 22, 2009, 7:07 PM EDT
I want to give you a trick. Take a screenshot of each style when your application runs. And then load the images for each visual style when the selected index changed in the ComboBox.
jinge
Aleksandar IlioskiRank #9,295 · 208 reputationPosted Oct 22, 2009, 7:37 PM EDT
jingeRank #2,527 · 554 reputationPosted Oct 22, 2009, 7:42 PM EDT
Trust me. If we have an easy and a stable way, why not borther finding trouble for yourself?
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 22, 2009, 8:34 PM EDT
Aleksandar IlioskiRank #9,295 · 208 reputationPosted Oct 22, 2009, 8:55 PM EDT
jingeRank #2,527 · 554 reputationPosted Oct 22, 2009, 9:37 PM EDT
Thank you for your information. It's always glad to see people who likes learning.
I think you can close a copy of the visual tree and apply the certain style, and then save them to the image.
Please see this article.
http://blogs.msdn.com/kirillosenkov/archive/2009/10/12/saving-images-bmp-png-etc-in-wpf-silverlight.aspx