<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>VBForums - C#</title>
		<link>http://www.vbforums.com/</link>
		<description>This forum is for all C# questions.</description>
		<language>en</language>
		<lastBuildDate>Thu, 20 Jun 2013 10:15:35 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.vbforums.com/images/misc/rss.png</url>
			<title>VBForums - C#</title>
			<link>http://www.vbforums.com/</link>
		</image>
		<item>
			<title>3.0/LINQ Add Icons to TreeView</title>
			<link>http://www.vbforums.com/showthread.php?725025-Add-Icons-to-TreeView&amp;goto=newpost</link>
			<pubDate>Mon, 17 Jun 2013 20:27:40 GMT</pubDate>
			<description>I recently just added directories and files to the treeView. How would I go about adding an icon for the folder nodes, and then a different icon for the file nodes? Thank you very much.</description>
			<content:encoded><![CDATA[<div>I recently just added directories and files to the treeView. How would I go about adding an icon for the folder nodes, and then a different icon for the file nodes? Thank you very much.</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>xAWx</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?725025-Add-Icons-to-TreeView</guid>
		</item>
		<item>
			<title>3.0/LINQ Help how to improve this code/make it more compact</title>
			<link>http://www.vbforums.com/showthread.php?724961-Help-how-to-improve-this-code-make-it-more-compact&amp;goto=newpost</link>
			<pubDate>Mon, 17 Jun 2013 11:44:28 GMT</pubDate>
			<description><![CDATA[Hi!

I am looking for ways to improve this block of code, similar kind of code is found throughout the application I am working on, and I wonder if there is a way to compact it, make it more readable and less error prone, maybe through some clever lablda syntax, extension methods etc?


Code:
---------
private void CopyToExcelExecute() {
            StringBuilder sb = new StringBuilder();
            Clipboard.Clear();
            foreach (var row in SelectedBOMRows) {
                if (row.BOMRow.Position != null)
                    sb.Append(row.BOMRow.Position.ToString());
                else
                    sb.Append(";");
                sb.Append(";");

                sb.Append(row.BOMRow.Level.ToString());
                sb.Append(";");

                if (row.BOMRow.ArticleReference != null) {
                    sb.Append(row.BOMRow.ArticleReference.Object.ArticleNumber);
                    sb.Append(";");
                    sb.Append(row.BOMRow.ArticleReference.Object.Title.DisplayText);
                    sb.Append(";");
                    sb.Append(row.BOMRow.ArticleReference.Quantity.ToString());
                    sb.Append(";");
                }
                else
                    sb.Append(";;;");

                sb.Append(row.BOMRow.Remark.DisplayText);

                if (row.BOMRow.SectionReference != null) {
                    sb.Append(";");
                    sb.Append(row.BOMRow.SectionReference.Object.Title.ToString());
                }
                else
                    sb.Append(";");
                sb.Append(Environment.NewLine);
               
            }
            Clipboard.SetText(sb.ToString(), TextDataFormat.CommaSeparatedValue);
           
        }
---------
I appreciate all assistance and input! Most of the code is boilerplate and I really wish I could remove the if/else checks and write some compact C# code instead...

/S]]></description>
			<content:encoded><![CDATA[<div>Hi!<br />
<br />
I am looking for ways to improve this block of code, similar kind of code is found throughout the application I am working on, and I wonder if there is a way to compact it, make it more readable and less error prone, maybe through some clever lablda syntax, extension methods etc?<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">private void CopyToExcelExecute() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StringBuilder sb = new StringBuilder();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Clipboard.Clear();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var row in SelectedBOMRows) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (row.BOMRow.Position != null)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(row.BOMRow.Position.ToString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(row.BOMRow.Level.ToString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (row.BOMRow.ArticleReference != null) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(row.BOMRow.ArticleReference.Object.ArticleNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(row.BOMRow.ArticleReference.Object.Title.DisplayText);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(row.BOMRow.ArticleReference.Quantity.ToString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;;;&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(row.BOMRow.Remark.DisplayText);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (row.BOMRow.SectionReference != null) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(row.BOMRow.SectionReference.Object.Title.ToString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(&quot;;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.Append(Environment.NewLine);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Clipboard.SetText(sb.ToString(), TextDataFormat.CommaSeparatedValue);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>I appreciate all assistance and input! Most of the code is boilerplate and I really wish I could remove the if/else checks and write some compact C# code instead...<br />
<br />
/S</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>MrNorth</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724961-Help-how-to-improve-this-code-make-it-more-compact</guid>
		</item>
		<item>
			<title>3.0/LINQ Filter TreeView Files</title>
			<link>http://www.vbforums.com/showthread.php?724887-Filter-TreeView-Files&amp;goto=newpost</link>
			<pubDate>Sun, 16 Jun 2013 03:16:58 GMT</pubDate>
			<description><![CDATA[I've been trying to get used to the TreeView control and this is what I have so far. I have a FolderBrowser, where you select the directory, and then it loads each file/folder into the TreeView. I was curious how I would go about filtering the file types that are allowed in the TreeView. I only want it to add .html files and folders. Here is my code so far:


Code:
---------
 private static void ListDirectory(TreeView treeView, string path)
        {
            treeView.Nodes.Clear();

            var stack = new Stack<TreeNode>();
            var rootDirectory = new DirectoryInfo(path);
            var node = new TreeNode(rootDirectory.Name) { Tag = rootDirectory };
            stack.Push(node);

            while (stack.Count > 0)
            {
                var currentNode = stack.Pop();
                var directoryInfo = (DirectoryInfo)currentNode.Tag;
                foreach (var directory in directoryInfo.GetDirectories())
                {
                    var childDirectoryNode = new TreeNode(directory.Name) { Tag = directory };
                    currentNode.Nodes.Add(childDirectoryNode);
                    stack.Push(childDirectoryNode);
                }
                foreach (var file in directoryInfo.GetFiles())
                {
                    currentNode.Nodes.Add(new TreeNode(file.Name));
                }
            }
            treeView.Nodes.Add(node);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            DialogResult dr = fbd.ShowDialog();

            if (dr == DialogResult.OK)
            {
                ListDirectory(treeView1, fbd.SelectedPath);
            }
        }
---------
Thanks in advance.]]></description>
			<content:encoded><![CDATA[<div>I've been trying to get used to the TreeView control and this is what I have so far. I have a FolderBrowser, where you select the directory, and then it loads each file/folder into the TreeView. I was curious how I would go about filtering the file types that are allowed in the TreeView. I only want it to add .html files and folders. Here is my code so far:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"> private static void ListDirectory(TreeView treeView, string path)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treeView.Nodes.Clear();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var stack = new Stack&lt;TreeNode&gt;();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var rootDirectory = new DirectoryInfo(path);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var node = new TreeNode(rootDirectory.Name) { Tag = rootDirectory };<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stack.Push(node);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (stack.Count &gt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var currentNode = stack.Pop();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var directoryInfo = (DirectoryInfo)currentNode.Tag;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var directory in directoryInfo.GetDirectories())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var childDirectoryNode = new TreeNode(directory.Name) { Tag = directory };<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentNode.Nodes.Add(childDirectoryNode);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stack.Push(childDirectoryNode);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var file in directoryInfo.GetFiles())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentNode.Nodes.Add(new TreeNode(file.Name));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treeView.Nodes.Add(node);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; private void button1_Click(object sender, EventArgs e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FolderBrowserDialog fbd = new FolderBrowserDialog();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DialogResult dr = fbd.ShowDialog();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (dr == DialogResult.OK)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ListDirectory(treeView1, fbd.SelectedPath);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>Thanks in advance.</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>xAWx</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724887-Filter-TreeView-Files</guid>
		</item>
		<item>
			<title>XAML - onmouseentered</title>
			<link>http://www.vbforums.com/showthread.php?724809-XAML-onmouseentered&amp;goto=newpost</link>
			<pubDate>Fri, 14 Jun 2013 23:02:04 GMT</pubDate>
			<description><![CDATA[I have an application using XAML for the interface. I have several buttons on the form. I've coded the onmouseentered and onmouseexited events to change the button state as the mouse goes over the buttons. This let's me swipe over the buttons and make them look pushed in (or simply change the button color). 

I'm actually doing this for a touch application, so I want a swipe of the finger to work the same way as the mouse. I'm finding the behavior to be a little odd. If I start my swipe outside of the buttons, then swiping over the buttons executes the two events and all is good. 

However - if I start the swipe on a button, then that button may (or may not) register the onmouseenter event and no other buttons in the swipe will register them as well. 

How can I swipe across the buttons and guarantee that the pointer/finger will be registered regardless of where I started?  Thoughts? 

As a note - I can think of some very complicated ways to do this, but it seems like it should be simple.]]></description>
			<content:encoded><![CDATA[<div>I have an application using XAML for the interface. I have several buttons on the form. I've coded the onmouseentered and onmouseexited events to change the button state as the mouse goes over the buttons. This let's me swipe over the buttons and make them look pushed in (or simply change the button color). <br />
<br />
I'm actually doing this for a touch application, so I want a swipe of the finger to work the same way as the mouse. I'm finding the behavior to be a little odd. If I start my swipe outside of the buttons, then swiping over the buttons executes the two events and all is good. <br />
<br />
However - if I start the swipe on a button, then that button may (or may not) register the onmouseenter event and no other buttons in the swipe will register them as well. <br />
<br />
How can I swipe across the buttons and guarantee that the pointer/finger will be registered regardless of where I started?  Thoughts? <br />
<br />
As a note - I can think of some very complicated ways to do this, but it seems like it should be simple.</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>brad jones</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724809-XAML-onmouseentered</guid>
		</item>
		<item>
			<title>OOP to students with JAVA background</title>
			<link>http://www.vbforums.com/showthread.php?724633-OOP-to-students-with-JAVA-background&amp;goto=newpost</link>
			<pubDate>Thu, 13 Jun 2013 08:26:27 GMT</pubDate>
			<description>Since JAVA and C# are almost identical is it still necessary to teach all the basics of C# like variable declaration, looping, if conditions, etc or can I just teach them how to make classes, encapsulation, and other more OOP-related topics?</description>
			<content:encoded><![CDATA[<div>Since JAVA and C# are almost identical is it still necessary to teach all the basics of C# like variable declaration, looping, if conditions, etc or can I just teach them how to make classes, encapsulation, and other more OOP-related topics?</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>dee-u</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724633-OOP-to-students-with-JAVA-background</guid>
		</item>
		<item>
			<title><![CDATA[[RESOLVED] copy property values from object to data contract]]></title>
			<link>http://www.vbforums.com/showthread.php?724581-RESOLVED-copy-property-values-from-object-to-data-contract&amp;goto=newpost</link>
			<pubDate>Wed, 12 Jun 2013 15:52:08 GMT</pubDate>
			<description><![CDATA[I've got an object i'm getting from a service written in cobol, i have a data contract in WCF that matches (property names and everything) identically to the cobol object.

i'm trying to use


Code:
---------
        public Dealer CopyPropertyValues(GetDealerInfo_dealerobject source, Dealer destination)
        {
            try
            {
                Type d = destination.GetType();
                Type s = source.GetType();
                foreach (var pi in d.GetProperties())
                {
                    foreach (var pz in s.GetProperties())
                    {
                        if (pi.Name.ToLower() == pz.Name.ToLower())
                        {
                            pi.SetValue(destination, pz.GetValue(source));
                        }
                    }
                }
            }
            catch (Exception e)
            {

            }
            return destination;
        }
---------
to try to copy the values from cobol to the dealer contract object that i can pass back to another calling program.

basically i'm creating a firewall/proxy system to isolate our cobol side from our website.

only problem is it gets through some of the properties but doesnt pick them all up, only the first few.  Unsure how to lengthen the timeout on the cobol side, i already have mine set at 25 minutes.]]></description>
			<content:encoded><![CDATA[<div>I've got an object i'm getting from a service written in cobol, i have a data contract in WCF that matches (property names and everything) identically to the cobol object.<br />
<br />
i'm trying to use<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&nbsp; &nbsp; &nbsp; &nbsp; public Dealer CopyPropertyValues(GetDealerInfo_dealerobject source, Dealer destination)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Type d = destination.GetType();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Type s = source.GetType();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var pi in d.GetProperties())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var pz in s.GetProperties())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (pi.Name.ToLower() == pz.Name.ToLower())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pi.SetValue(destination, pz.GetValue(source));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch (Exception e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return destination;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>to try to copy the values from cobol to the dealer contract object that i can pass back to another calling program.<br />
<br />
basically i'm creating a firewall/proxy system to isolate our cobol side from our website.<br />
<br />
only problem is it gets through some of the properties but doesnt pick them all up, only the first few.  Unsure how to lengthen the timeout on the cobol side, i already have mine set at 25 minutes.</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>DirtyHowi</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724581-RESOLVED-copy-property-values-from-object-to-data-contract</guid>
		</item>
		<item>
			<title>Regex help</title>
			<link>http://www.vbforums.com/showthread.php?724485-Regex-help&amp;goto=newpost</link>
			<pubDate>Tue, 11 Jun 2013 15:51:45 GMT</pubDate>
			<description><![CDATA[I've got a string such as:

"3;#bctest/Lists/Test List 1/Folder 1\"

I want to use Regex to extract that last folder, in this case: "Folder 1"

So essentially, I need to always extract the string immediately after the last forward slash (/), without including the last backslash (\).  It's important to note that the string can contain any number of forward slashes, but I'm only interested in the last forward slash.

Any help would be appreciated.]]></description>
			<content:encoded><![CDATA[<div>I've got a string such as:<br />
<br />
&quot;3;#bctest/Lists/Test List 1/Folder 1\&quot;<br />
<br />
I want to use Regex to extract that last folder, in this case: &quot;Folder 1&quot;<br />
<br />
So essentially, I need to always extract the string immediately after the last forward slash (/), without including the last backslash (\).  It's important to note that the string can contain any number of forward slashes, but I'm only interested in the last forward slash.<br />
<br />
Any help would be appreciated.</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>softwareguy74</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724485-Regex-help</guid>
		</item>
		<item>
			<title><![CDATA[[RESOLVED] Retrieve value from table and How to store in string variable]]></title>
			<link>http://www.vbforums.com/showthread.php?724463-RESOLVED-Retrieve-value-from-table-and-How-to-store-in-string-variable&amp;goto=newpost</link>
			<pubDate>Tue, 11 Jun 2013 13:03:29 GMT</pubDate>
			<description><![CDATA[Hello,

I want to store some data to string array that came from Database table.

 

*The table Data is (only a column):*

Alice Mutton
Aniseed Syrup
Boston Crab Meat
Camembert Pierrot
Carnarvon Tigers

...

...

 

*I want to store this retrieved data to String array like (Programetically):*

string[] data = {"Alice Mutton", "Aniseed Syrup", "Boston Crab Meat", "Camembert Pierrot", "Carnarvon Tigers"};

 

How can I fix it?

 

best regards

ehsan]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I want to store some data to string array that came from Database table.<br />
<br />
 <br />
<br />
<b>The table Data is (only a column):</b><br />
<br />
Alice Mutton<br />
Aniseed Syrup<br />
Boston Crab Meat<br />
Camembert Pierrot<br />
Carnarvon Tigers<br />
<br />
...<br />
<br />
...<br />
<br />
 <br />
<br />
<b>I want to store this retrieved data to String array like (Programetically):</b><br />
<br />
string[] data = {&quot;Alice Mutton&quot;, &quot;Aniseed Syrup&quot;, &quot;Boston Crab Meat&quot;, &quot;Camembert Pierrot&quot;, &quot;Carnarvon Tigers&quot;};<br />
<br />
 <br />
<br />
How can I fix it?<br />
<br />
 <br />
<br />
best regards<br />
<br />
ehsan</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>ehsan85</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724463-RESOLVED-Retrieve-value-from-table-and-How-to-store-in-string-variable</guid>
		</item>
		<item>
			<title>UDP. What am I doing wrong</title>
			<link>http://www.vbforums.com/showthread.php?724181-UDP-What-am-I-doing-wrong&amp;goto=newpost</link>
			<pubDate>Sat, 08 Jun 2013 12:37:14 GMT</pubDate>
			<description><![CDATA[I've got two programs. One sending a UDP message. The other is receiving it.

The sender sends a message every second or so. I can send faster or slower. It doesn't make any difference. The receiver only receives every alternate message. So, to make it work I send each message twice and the receiver receives once. I could run with this but I shouldn't need to send twice - should I ?

If I send different messages I can see that the problem is in the receiver. I suspect the callback isn't being setup correctly. It's as if the callback has to have two messages in the receive queue  before it fires the DataReceived event with the4 second one.

Any ideas what I'm doing wrong ?



Code:
---------
// This is the SENDER

public static Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,ProtocolType.Udp );
static System.Net.IPAddress serverAddr = System.Net.IPAddress.Parse("127.0.0.1");
static System.Net.IPEndPoint endPoint = new System.Net.IPEndPoint(serverAddr, 11000);

public static void soc_Send(string s)  // Sender calls this when it wants to send a message.
{
     byte[] send_buffer = Encoding.ASCII.GetBytes(s);

     sock.SendTo(send_buffer, endPoint);

     *// If I Un-Comment this next line then we'll repeat. But the receiver will only receive one message
     //sock.SendTo(send_buffer, endPoint);*

}
---------


Code:
---------
// This is the RECEIVER

UdpClient client new UdpClient(11000);
UdpState state = new UdpState();
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
// IPEndPoint RemoteIpEndPoint = new IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 11000);

private void Form1_Load(object sender, EventArgs e)
{
     client.BeginReceive(new AsyncCallback(DataReceived), state);
}

private void DataReceived(IAsyncResult ar)
{
     Byte[] rxBytes = client.Receive(ref RemoteIpEndPoint); 

     string s = ASCIIEncoding.ASCII.GetString(rxBytes);

     // Do something with the data     

     // Setup the callback for another event
     client.BeginReceive(new AsyncCallback(DataReceived), state);
  
}
---------
]]></description>
			<content:encoded><![CDATA[<div>I've got two programs. One sending a UDP message. The other is receiving it.<br />
<br />
The sender sends a message every second or so. I can send faster or slower. It doesn't make any difference. The receiver only receives every alternate message. So, to make it work I send each message twice and the receiver receives once. I could run with this but I shouldn't need to send twice - should I ?<br />
<br />
If I send different messages I can see that the problem is in the receiver. I suspect the callback isn't being setup correctly. It's as if the callback has to have two messages in the receive queue  before it fires the DataReceived event with the4 second one.<br />
<br />
Any ideas what I'm doing wrong ?<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">// This is the SENDER<br />
<br />
public static Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,ProtocolType.Udp );<br />
static System.Net.IPAddress serverAddr = System.Net.IPAddress.Parse(&quot;127.0.0.1&quot;);<br />
static System.Net.IPEndPoint endPoint = new System.Net.IPEndPoint(serverAddr, 11000);<br />
<br />
public static void soc_Send(string s)&nbsp; // Sender calls this when it wants to send a message.<br />
{<br />
&nbsp; &nbsp;  byte[] send_buffer = Encoding.ASCII.GetBytes(s);<br />
<br />
&nbsp; &nbsp;  sock.SendTo(send_buffer, endPoint);<br />
<br />
&nbsp; &nbsp;  <b><font color="#008000">// If I Un-Comment this next line then we'll repeat. But the receiver will only receive one message</font><br />
&nbsp; &nbsp;  //sock.SendTo(send_buffer, endPoint);</b><br />
<br />
}</code><hr />
</div><br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">// This is the RECEIVER<br />
<br />
UdpClient client new UdpClient(11000);<br />
UdpState state = new UdpState();<br />
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);<br />
<font color="#008000">// IPEndPoint RemoteIpEndPoint = new IPEndPoint(System.Net.IPAddress.Parse(&quot;127.0.0.1&quot;), 11000);</font><br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
&nbsp; &nbsp;  client.BeginReceive(new AsyncCallback(DataReceived), state);<br />
}<br />
<br />
private void DataReceived(IAsyncResult ar)<br />
{<br />
&nbsp; &nbsp;  Byte[] rxBytes = client.Receive(ref RemoteIpEndPoint); <br />
<br />
&nbsp; &nbsp;  string s = ASCIIEncoding.ASCII.GetString(rxBytes);<br />
<br />
&nbsp; &nbsp;  <font color="#008000">// Do something with the data</font>&nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp;  <font color="#008000">// Setup the callback for another event</font><br />
&nbsp; &nbsp;  client.BeginReceive(new AsyncCallback(DataReceived), state);<br />
&nbsp; <br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>Axcontrols</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724181-UDP-What-am-I-doing-wrong</guid>
		</item>
		<item>
			<title><![CDATA[[RESOLVED] Closing application from outside "main" ran form?]]></title>
			<link>http://www.vbforums.com/showthread.php?724045-RESOLVED-Closing-application-from-outside-quot-main-quot-ran-form&amp;goto=newpost</link>
			<pubDate>Thu, 06 Jun 2013 16:24:36 GMT</pubDate>
			<description><![CDATA[My application is growing quite fast, I'm up to about 15 different forms and 20 different classes (at least). However, I seem to be stuck trying to *fully* close the entire application.

Now, I know that inside the Program.cs, there is the line of 
Code:
---------
Application.Run(new MainForm()); //We use MainForm instead of Form1
---------
As far as I understand it, closing MainForm from anywhere results in the entire application unloading, calling every forms/classes closing/disposing events if necessary. However, what if I'm trying to close/unload the application in another way.

In Program.cs I hook the CurrentDomain_UnhandledException event. Inside of that, I log the error message inside a try block, and in a finally block, call 
Code:
---------
Application.Exit()
---------
This seems to successfully close/unload the entire application and there are no lingering processes of my app running.

With that in mind, I don't display the MainForm right away, it doesn't show in the taskbar and is minimized on startup. I then show a new form, for logging into the application and handling other things for the user before restoring the MainForm. On the closing event of the Login form, all I do is call Application.Exit() and in every test it correctly closes/unloads the application and there are no lingering processes of my app running.

I have 1 more form that gets displayed on certain user settings upon logging in. The Login form is minimized and .Hide() is called on it while the main form is restored. On restoring the main form, if it needs to be, I show a Settings form right overtop the MainForm. This is all currently working exactly how I would like it to so far. On the Settings form though, I have an "Exit Program" button. Since you have to complete the entire Settings form to get into the main application, I figured some people might choose to save their progress/settings and continue later. Thus, if the "Exit Program" button is clicked, SQL saves the currently set settings and calls 
Code:
---------
Application.Exit();
---------
 However, it's at this point that the Settings form closes, the MainForm closes (remember it's restored and shown in taskbar) as I can see it go away, but I still have the a lingering process. If inside of the IDE, VS doesn't stop the debugging session as something is apparently running but not crashing the program...

I am more than curious as to why Application.Exit() is correctly working in 2 completely different areas of code, but yet another area of code, it only semi works?]]></description>
			<content:encoded><![CDATA[<div>My application is growing quite fast, I'm up to about 15 different forms and 20 different classes (at least). However, I seem to be stuck trying to <b>fully</b> close the entire application.<br />
<br />
Now, I know that inside the Program.cs, there is the line of <div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Application.Run(new MainForm()); //We use MainForm instead of Form1</code><hr />
</div>As far as I understand it, closing MainForm from anywhere results in the entire application unloading, calling every forms/classes closing/disposing events if necessary. However, what if I'm trying to close/unload the application in another way.<br />
<br />
In Program.cs I hook the CurrentDomain_UnhandledException event. Inside of that, I log the error message inside a try block, and in a finally block, call <div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Application.Exit()</code><hr />
</div>This seems to successfully close/unload the entire application and there are no lingering processes of my app running.<br />
<br />
With that in mind, I don't display the MainForm right away, it doesn't show in the taskbar and is minimized on startup. I then show a new form, for logging into the application and handling other things for the user before restoring the MainForm. On the closing event of the Login form, all I do is call Application.Exit() and in every test it correctly closes/unloads the application and there are no lingering processes of my app running.<br />
<br />
I have 1 more form that gets displayed on certain user settings upon logging in. The Login form is minimized and .Hide() is called on it while the main form is restored. On restoring the main form, if it needs to be, I show a Settings form right overtop the MainForm. This is all currently working exactly how I would like it to so far. On the Settings form though, I have an &quot;Exit Program&quot; button. Since you have to complete the entire Settings form to get into the main application, I figured some people might choose to save their progress/settings and continue later. Thus, if the &quot;Exit Program&quot; button is clicked, SQL saves the currently set settings and calls <div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Application.Exit();</code><hr />
</div> However, it's at this point that the Settings form closes, the MainForm closes (remember it's restored and shown in taskbar) as I can see it go away, but I still have the a lingering process. If inside of the IDE, VS doesn't stop the debugging session as something is apparently running but not crashing the program...<br />
<br />
I am more than curious as to why Application.Exit() is correctly working in 2 completely different areas of code, but yet another area of code, it only semi works?</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>detlion1643</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?724045-RESOLVED-Closing-application-from-outside-quot-main-quot-ran-form</guid>
		</item>
		<item>
			<title><![CDATA[[RESOLVED] Time Comparisons]]></title>
			<link>http://www.vbforums.com/showthread.php?723899-RESOLVED-Time-Comparisons&amp;goto=newpost</link>
			<pubDate>Wed, 05 Jun 2013 13:23:31 GMT</pubDate>
			<description><![CDATA[I want to compare the system time to a set time, but am not sure how to set that up.  For example, I want to do this

Code:
---------
        private static void TimeCompare()
        {
            if (DateTime.Now.TimeOfDay < "11:00:00")
            {
                MessageBox.Show("It's before 11");
            }
            else
            {
                MessageBox.Show("It's after 11");
            }
        }
---------
But on the time comparison I get the compile error of
Operator < can not be applied to operands of type System.TimeSpan and String.

How would one make such comparison in C#?]]></description>
			<content:encoded><![CDATA[<div>I want to compare the system time to a set time, but am not sure how to set that up.  For example, I want to do this<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&nbsp; &nbsp; &nbsp; &nbsp; private static void TimeCompare()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (DateTime.Now.TimeOfDay &lt; &quot;11:00:00&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show(&quot;It's before 11&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show(&quot;It's after 11&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>But on the time comparison I get the compile error of<br />
Operator &lt; can not be applied to operands of type System.TimeSpan and String.<br />
<br />
How would one make such comparison in C#?</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>Jo15765</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?723899-RESOLVED-Time-Comparisons</guid>
		</item>
		<item>
			<title>Thread has not yet started</title>
			<link>http://www.vbforums.com/showthread.php?723761-Thread-has-not-yet-started&amp;goto=newpost</link>
			<pubDate>Tue, 04 Jun 2013 08:18:27 GMT</pubDate>
			<description><![CDATA[Dear All,

I am using VS2010, Netframework4, why I am facing with "Thread has not yet started" ..:confused:

Thread t;
t = new Thread(new ParameterizedThreadStart(mycounters));
t.Start(new object[] { para1, para2, para3 });

t.Join();   // THE EXCEPTION GOES HERE!


private void mycounters(object parameters)
{
..
..
..
}

Please help

Thanks & Regards]]></description>
			<content:encoded><![CDATA[<div>Dear All,<br />
<br />
I am using VS2010, Netframework4, why I am facing with &quot;Thread has not yet started&quot; ..:confused:<br />
<br />
Thread t;<br />
t = new Thread(new ParameterizedThreadStart(mycounters));<br />
t.Start(new object[] { para1, para2, para3 });<br />
<br />
t.Join();   // THE EXCEPTION GOES HERE!<br />
<br />
<br />
private void mycounters(object parameters)<br />
{<br />
..<br />
..<br />
..<br />
}<br />
<br />
Please help<br />
<br />
Thanks &amp; Regards</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>Winanjaya</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?723761-Thread-has-not-yet-started</guid>
		</item>
		<item>
			<title><![CDATA[3.0/LINQ XML --> get node elements using Index]]></title>
			<link>http://www.vbforums.com/showthread.php?723295-XML-gt-get-node-elements-using-Index&amp;goto=newpost</link>
			<pubDate>Thu, 30 May 2013 14:58:51 GMT</pubDate>
			<description><![CDATA[Hi there,

I created a small app using a combobox and a XML file. If I choose a material from the list I get returned an index of the specific node. How do I assign all element from this node to variables?

Here is the code:


Code:
---------
<?xml version="1.0" encoding="utf-8" ?>
<Materialien>
  <Material name="Wählen">
    <Zerspanungsgruppe>P1</Zerspanungsgruppe>
    <minZug>0</minZug>
    <maxZug>0</maxZug>
  </Material>
  <Material name="1.0036">
    <Zerspanungsgruppe>P1</Zerspanungsgruppe>
    <minZug>360</minZug>
    <maxZug>510</maxZug>
  </Material>
  <Material name="1.0037">
    <Zerspanungsgruppe>P1</Zerspanungsgruppe>
    <minZug>360</minZug>
    <maxZug>510</maxZug>
  </Material>
</Materialien>
---------
I.e. I get returned  the index "1" I would like to assign each element to a variable:
a = P1
b = 360
c = 510

Cheers
Moritz]]></description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
I created a small app using a combobox and a XML file. If I choose a material from the list I get returned an index of the specific node. How do I assign all element from this node to variables?<br />
<br />
Here is the code:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;<br />
&lt;Materialien&gt;<br />
&nbsp; &lt;Material name=&quot;Wählen&quot;&gt;<br />
&nbsp; &nbsp; &lt;Zerspanungsgruppe&gt;P1&lt;/Zerspanungsgruppe&gt;<br />
&nbsp; &nbsp; &lt;minZug&gt;0&lt;/minZug&gt;<br />
&nbsp; &nbsp; &lt;maxZug&gt;0&lt;/maxZug&gt;<br />
&nbsp; &lt;/Material&gt;<br />
&nbsp; &lt;Material name=&quot;1.0036&quot;&gt;<br />
&nbsp; &nbsp; &lt;Zerspanungsgruppe&gt;P1&lt;/Zerspanungsgruppe&gt;<br />
&nbsp; &nbsp; &lt;minZug&gt;360&lt;/minZug&gt;<br />
&nbsp; &nbsp; &lt;maxZug&gt;510&lt;/maxZug&gt;<br />
&nbsp; &lt;/Material&gt;<br />
&nbsp; &lt;Material name=&quot;1.0037&quot;&gt;<br />
&nbsp; &nbsp; &lt;Zerspanungsgruppe&gt;P1&lt;/Zerspanungsgruppe&gt;<br />
&nbsp; &nbsp; &lt;minZug&gt;360&lt;/minZug&gt;<br />
&nbsp; &nbsp; &lt;maxZug&gt;510&lt;/maxZug&gt;<br />
&nbsp; &lt;/Material&gt;<br />
&lt;/Materialien&gt;</code><hr />
</div>I.e. I get returned  the index &quot;1&quot; I would like to assign each element to a variable:<br />
a = P1<br />
b = 360<br />
c = 510<br />
<br />
Cheers<br />
Moritz</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>Moritz83</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?723295-XML-gt-get-node-elements-using-Index</guid>
		</item>
		<item>
			<title>Not switching to code when debugging.</title>
			<link>http://www.vbforums.com/showthread.php?723177-Not-switching-to-code-when-debugging&amp;goto=newpost</link>
			<pubDate>Wed, 29 May 2013 13:21:35 GMT</pubDate>
			<description><![CDATA[I am using VS 2010 and my issue is my application is not switching to the code when it hits a breakpoint.  The application starts on the main mdi screen and the switches to another screen.  After leaving a text box the application hits a breakpoint but it doesn't switch to the code.  Even when I try to go to the code it switches back to the application.  I have tried everything I could to make it stay on the code for debugging but it will not stay.]]></description>
			<content:encoded><![CDATA[<div>I am using VS 2010 and my issue is my application is not switching to the code when it hits a breakpoint.  The application starts on the main mdi screen and the switches to another screen.  After leaving a text box the application hits a breakpoint but it doesn't switch to the code.  Even when I try to go to the code it switches back to the application.  I have tried everything I could to make it stay on the code for debugging but it will not stay.</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>Mrrenzo0861</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?723177-Not-switching-to-code-when-debugging</guid>
		</item>
		<item>
			<title>Bouncing Ball not working properly</title>
			<link>http://www.vbforums.com/showthread.php?722913-Bouncing-Ball-not-working-properly&amp;goto=newpost</link>
			<pubDate>Sun, 26 May 2013 15:39:37 GMT</pubDate>
			<description><![CDATA[Hello , Im creating a game like bounce , for that i was creating a code for continues bouncing of ball , it will bounce after getting to bottom of form 
i have added a acceleration to make bouncing realistic , but each time when it rebounds from bottom of form  it does not attain same height as before and after same rebounds it is almost at bottom ( like real ball as it will keep bouncing at low height each time , but i dont want this to happen )

my second problem is , im redrawing ball with form paint event each 100 ms (its velocity is also calculated with 100 ms interval) , but as velocity of ball increases , it looks like skipping of frames (lagging) of ball , it does not look smooth , i want to fix that too , 

im currently using normal c # to create this game , can someone give me example of creating game with XNA framework (or other like it integrated with VS2012)

Here is my code:_ ( this is whole code , u can add it to any form with button1 and test it )

Code:
---------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace bounce
{
    public partial class Form1 : Form
    {
        int dx;
        int dy;
        int x;
        int y;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            Random rnd = new Random();
            dx = 1;
            dy = 1;
            x = 100 ; //rnd.Next(0, this.ClientSize.Width - 50);
            y = 0;// rnd.Next(0, this.ClientSize.Height - 50);


        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            e.Graphics.Clear(this.BackColor);
            e.Graphics.FillEllipse(Brushes.Black, x, y, 50, 50);
            e.Graphics.DrawEllipse(Pens.Black, x, y, 50, 50);
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (button1.Text == "start")
            {
                ToBounce = true;
                System.Threading.Thread newThread;
                newThread = new System.Threading.Thread(startmechBounceOnFormBottem);
                newThread.Start();

                // timer1.Enabled = true;
                button1.Text = "stop";
                return;
            }
            else if (button1.Text == "stop")
            {
                ToBounce = false;
                //timer1.Enabled = false;
                button1.Text = "start";
                return;
            }

        }

        Boolean ToBounce;
        Boolean GoingUP;
        private void startmechBounceOnFormBottem()
        {
            GoingUP = false;
            int a = 1;
            int uY = 0;
            ToBounce = true;
            while (ToBounce == true)
            {
                Thread.Sleep(100);
                if (y >= 0 && y < this.ClientSize.Height - 50)
                {
                    if (GoingUP == false)
                    {
                        uY = uY + a;
                        if (y + uY > this.ClientSize.Height - 50)
                        {
                            y = this.ClientSize.Height - 50;
                            this.Invalidate();
                        }
                        else
                        {
                            y = y + uY;
                        }
                    }
                    else if (GoingUP == true)
                    {
                        if (uY <= 0)
                        {
                            GoingUP = false;
                        }
                        else
                        {
                            uY = uY - a;
                            y = y - uY;
                        }

                    }

                }
                else if (y >= this.ClientSize.Height - 50)
                {
                    y = this.ClientSize.Height - 50;
                    this.Invalidate();
                    uY = uY - a;
                    y = y - uY;
                    GoingUP = true;
                }

                this.Invalidate();

             

            }

        }
    }
}
---------
]]></description>
			<content:encoded><![CDATA[<div>Hello , Im creating a game like bounce , for that i was creating a code for continues bouncing of ball , it will bounce after getting to bottom of form <br />
i have added a acceleration to make bouncing realistic , but each time when it rebounds from bottom of form  it does not attain same height as before and after same rebounds it is almost at bottom ( like real ball as it will keep bouncing at low height each time , but i dont want this to happen )<br />
<br />
my second problem is , im redrawing ball with form paint event each 100 ms (its velocity is also calculated with 100 ms interval) , but as velocity of ball increases , it looks like skipping of frames (lagging) of ball , it does not look smooth , i want to fix that too , <br />
<br />
im currently using normal c # to create this game , can someone give me example of creating game with XNA framework (or other like it integrated with VS2012)<br />
<br />
Here is my code:_ ( this is whole code , u can add it to any form with button1 and test it )<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Diagnostics;<br />
using System.Drawing;<br />
using System.Drawing.Drawing2D;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Threading;<br />
using System.Threading.Tasks;<br />
using System.Windows.Forms;<br />
<br />
namespace bounce<br />
{<br />
&nbsp; &nbsp; public partial class Form1 : Form<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; int dx;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int dy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; public Form1()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitializeComponent();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; private void Form1_Load(object sender, EventArgs e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Random rnd = new Random();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dx = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dy = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = 100 ; //rnd.Next(0, this.ClientSize.Width - 50);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = 0;// rnd.Next(0, this.ClientSize.Height - 50);<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; private void Form1_Paint(object sender, PaintEventArgs e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.Graphics.Clear(this.BackColor);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.Graphics.FillEllipse(Brushes.Black, x, y, 50, 50);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.Graphics.DrawEllipse(Pens.Black, x, y, 50, 50);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; private void button1_Click(object sender, EventArgs e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (button1.Text == &quot;start&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ToBounce = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.Threading.Thread newThread;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newThread = new System.Threading.Thread(startmechBounceOnFormBottem);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newThread.Start();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // timer1.Enabled = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; button1.Text = &quot;stop&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (button1.Text == &quot;stop&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ToBounce = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //timer1.Enabled = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; button1.Text = &quot;start&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Boolean ToBounce;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Boolean GoingUP;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private void startmechBounceOnFormBottem()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoingUP = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int a = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int uY = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ToBounce = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (ToBounce == true)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.Sleep(100);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y &gt;= 0 &amp;&amp; y &lt; this.ClientSize.Height - 50)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (GoingUP == false)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uY = uY + a;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y + uY &gt; this.ClientSize.Height - 50)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = this.ClientSize.Height - 50;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.Invalidate();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = y + uY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (GoingUP == true)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (uY &lt;= 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoingUP = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uY = uY - a;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = y - uY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (y &gt;= this.ClientSize.Height - 50)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = this.ClientSize.Height - 50;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.Invalidate();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uY = uY - a;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = y - uY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GoingUP = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.Invalidate();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?30-C">C#</category>
			<dc:creator>Binarybot</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?722913-Bouncing-Ball-not-working-properly</guid>
		</item>
	</channel>
</rss>
