It is currently Fri May 31, 2024 6:16 am


). Not really visualizing I suppose, but you can come to understand the topography, where a 4D cube has 6 faces that are 3D solids, and each edge has three faces. Yeah, weird. 






Some people think they can outsmart me. <sniff> Maybe.... Maybe...
... I have yet to meet one who can outsmart boolet!

theCommie wrote:Coder, please tell me you have a job doing this kind of stuff (Granted, I don't know how complex/easy/hard it is to code that - or to code at all); seems like you should with your prowess.




private Form ParseXMLtoForm(string text)
{
XmlDocument doc = new XmlDocument();
doc.Load(new System.IO.StringReader(text));
XmlNodeList xnl = doc.GetElementsByTagName("form");
if (xnl.Count != 1) throw new Exception("xml specification of form must have a single root element with the 'form' tag");
Form f = new Form();
foreach (XmlAttribute attr in xnl[0].Attributes)
SetProperty(f, attr.Name, attr.Value);
FlowLayoutPanel flp = new FlowLayoutPanel();
flp.FlowDirection = FlowDirection.LeftToRight;
flp.Dock = DockStyle.Fill;
f.Controls.Add(flp);
Queue<KeyValuePair<XmlNode, Control>> todo = new Queue<KeyValuePair<XmlNode, Control>>();
string controlfilter = typeof(Control).AssemblyQualifiedName.Replace("Control", "{0}");
foreach (XmlNode x in xnl[0].ChildNodes)
todo.Enqueue(new KeyValuePair<XmlNode, Control>(x, flp));
while (todo.Count > 0)
{
KeyValuePair<XmlNode, Control> p = todo.Dequeue();
if (Type.GetType(string.Format(controlfilter,p.Key.Name), false, true) == null) continue;
Type t = Type.GetType(string.Format(controlfilter, p.Key.Name), true, true);
if (!t.IsSubclassOf(typeof(Control))) continue;
Control newControl = (Control) Activator.CreateInstance(t);
(p.Value as Control).Controls.Add(newControl);
foreach (XmlAttribute attr in p.Key.Attributes)
SetProperty(newControl, attr.Name, attr.Value);
if (t == typeof(Panel) || t == typeof(GroupBox) || t == typeof(FlowLayoutPanel))
{
if (t != typeof(FlowLayoutPanel))
{
FlowLayoutPanel pan = new FlowLayoutPanel();
pan.FlowDirection = FlowDirection.LeftToRight;
pan.Dock = DockStyle.Fill;
newControl.Controls.Add(pan);
newControl = pan;
}
foreach(XmlNode node in p.Key.ChildNodes)
todo.Enqueue(new KeyValuePair<XmlNode,Control>(node,newControl));
}
}
return f;
}
private void SetProperty(object subject, string property, string value)
{
Type t = subject.GetType();
try
{
object o = 0;
PropertyInfo pi = t.GetProperty(property, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.Public);
if (pi.PropertyType == typeof(string))
o = value;
else if (pi.PropertyType == typeof(decimal))
{
decimal d = 0;
decimal.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out d);
o = d;
}
else if (pi.PropertyType == typeof(int))
{
int i = 0;
int.TryParse(value, out i);
o = i;
}
else if (pi.PropertyType == typeof(bool))
o = !(value == "0" || value == "" || value == "false");
else if (pi.PropertyType == typeof(Color))
o = ColorTranslator.FromHtml(value);
else if (pi.PropertyType == typeof(Icon))
o = Icon.FromHandle((new Bitmap(value)).GetHicon());
pi.SetValue(subject, o, null);
}
catch
{
try
{
EventInfo ei = t.GetEvent(property, BindingFlags.IgnoreCase);
//TODO: ei.AddEventHandler(w, new delegate()); //todo: add delegate here
}
catch { }
}
}
}
<form name="test" text="water" icon="D:\My Pictures\images\attach.png" width="200" height="300">
<groupbox text="groupbox1">
<button text="button01" />
<textbox text="example input" />
</groupbox>
<progressbar maximum="200" value="150" />
<label text="hello, this is a label" />
<button text="Ok" />
<button text="Cancel" enabled="false" />
<picturebox sizemode="4" width="128" height="128" image="D:\My Pictures\icons\drwho.ico" />
</form>





source-maps wrote:





bool IsCoder(bool understandsBinary)
{
return understandsBinary;
}String searchQuery = "interlopers.net";XHTMLDocument searchResultsPage =
XHTMLDocument.LoadPageFromURL("http://www.google.com/search?hl=en&q=" + searchQuery);List<XMLElement> allResults = searchResultsPage.FindElements("h3", "class", "r");XMLElement firstResult = allResults[0];XMLElement anchorTagOfFirstResult = firstResult.FindElements("a", null)[0];String firstResultURL = anchorTagOfFirstResult.GetAttribute("href");

Users browsing this forum: No registered users