<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5288223254146567013</id><updated>2012-02-01T05:05:50.079-08:00</updated><category term='validation attrubutes'/><category term='WPF Idataerrorinfo'/><category term='c#'/><category term='background thread'/><category term='validations in wpf'/><category term='Task factory'/><category term='c# 4.0'/><category term='Multitasking In WPF'/><category term='WPF form validations'/><title type='text'>Venky's</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-566071533537958876</id><published>2011-09-14T09:10:00.000-07:00</published><updated>2012-02-01T05:05:50.091-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='validation attrubutes'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><title type='text'>Custom Validation Attributes</title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-566071533537958876?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/566071533537958876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/09/custom-validation-attributes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/566071533537958876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/566071533537958876'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/09/custom-validation-attributes.html' title='Custom Validation Attributes'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-8798507160082453446</id><published>2011-09-12T06:07:00.000-07:00</published><updated>2011-09-12T06:20:46.526-07:00</updated><title type='text'>Named and Optional Parameters C# 4.0 Feature</title><content type='html'>Optional parameter and name parameters are 2 different features in c# 4.0.&lt;br /&gt;&lt;br /&gt;let us first discuss optional parameters.&lt;br /&gt;let us consider we have write few method to add 2,3 and 4 numbers.&lt;br /&gt;&lt;br /&gt;what we used to this is writing overload method with same name and different parameters.  &lt;br /&gt;&lt;br /&gt;some thing like this&lt;br /&gt;public int Add(int a, int b)&lt;br /&gt;{&lt;br /&gt;//logic&lt;br /&gt;}&lt;br /&gt;public int Add(int a, int b, int c)&lt;br /&gt;{&lt;br /&gt;//logic&lt;br /&gt;}&lt;br /&gt;public int Add(int a, int b, int c, int d)&lt;br /&gt;{&lt;br /&gt;//logic&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now with optional parameters we can simple  write one single method to handle this method over loading situation&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;public int Add(int a, int b, int c = 0, int d = 0)&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;in the above code we have given default values to c and d means while calling this method if we don't pas parameter for c and d then 0 will be consider as default value so here C and D are optional parameters.&lt;br /&gt;&lt;br /&gt;Add(1, 2); //c and d are optional  &lt;br /&gt;Add(1, 2, 3); // d is optional &lt;br /&gt;Add(1, 2, 3, 4);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Coming to named parameters&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;let us consider we are creating employee details&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;public void CreateEmployee(string name, int age = 22,string address = "Not specified");&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;with named parameters we call call this method irrespective of order of the  parametes&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;CreateEmployee("Venkatesh", age: 28);&lt;br /&gt;CreateEmployee(address: "Hyderabad", name: "Venkatesh");&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-8798507160082453446?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/8798507160082453446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/09/named-and-optional-parameters-c-40.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/8798507160082453446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/8798507160082453446'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/09/named-and-optional-parameters-c-40.html' title='Named and Optional Parameters C# 4.0 Feature'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-4507622922606471314</id><published>2011-09-02T03:05:00.001-07:00</published><updated>2011-09-02T03:13:46.898-07:00</updated><title type='text'>Fix for Loveseat CouchDB Login Session Issue</title><content type='html'>There is a bug in CouchDB (love seat) regarding maintaining user session.. &lt;br /&gt;&lt;br /&gt;In CouchBase.cs class the method GetSession is not returning the value it has created in cookie. it is simply returning "cookie" from that method... which is always null.. it leads to user expiry immediatly after login though that use session is ready in cookie...&lt;br /&gt;&lt;br /&gt;delete that method from you couchbase and use the following method&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight:bold;"&gt;protected Cookie GetSession()&lt;br /&gt;        {&lt;br /&gt;            var cookie = cookiestore["authcookie"];&lt;br /&gt;&lt;br /&gt;            if (cookie != null)&lt;br /&gt;                return cookie;&lt;br /&gt;&lt;br /&gt;            if (string.IsNullOrEmpty(username)) return null;&lt;br /&gt;            var request = new CouchRequest(baseUri + "_session");&lt;br /&gt;            var response = request.Post()&lt;br /&gt;                .ContentType("application/x-www-form-urlencoded")&lt;br /&gt;                .Data("name=" + username + "&amp;password=" + password)&lt;br /&gt;                .GetResponse();&lt;br /&gt;&lt;br /&gt;            var header = response.Headers.Get("Set-Cookie");&lt;br /&gt;            if (header != null)&lt;br /&gt;            {&lt;br /&gt;                var parts = header.Split(';')[0].Split('=');&lt;br /&gt;                var authCookie = new Cookie(parts[0], parts[1]);&lt;br /&gt;                authCookie.Domain = response.Server;&lt;br /&gt;                cookiestore.Add("authcookie", authCookie, TimeSpan.FromMinutes(9));&lt;br /&gt;            }&lt;br /&gt;            return cookiestore["authcookie"];&lt;br /&gt;        }&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-4507622922606471314?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/4507622922606471314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/09/fix-for-loveseat-couchdb-login-session.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/4507622922606471314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/4507622922606471314'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/09/fix-for-loveseat-couchdb-login-session.html' title='Fix for Loveseat CouchDB Login Session Issue'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-7762085589298858977</id><published>2011-09-02T03:04:00.001-07:00</published><updated>2011-09-02T03:04:41.797-07:00</updated><title type='text'>Creating Database admin user In CouchDB using LoveSeat (C#)</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;Here is a method for LoveSeat Api which will create a database admin used for Couch DB&lt;br /&gt;&lt;br /&gt;Copy this method to CouchClient.cs in loveseat api and it is ready to use....&lt;br /&gt;&lt;br /&gt;make sure to create couch DB connection with admin privileges to use this method&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt; &lt;b&gt;&lt;br /&gt;public JObject CreateDatabaseAdminUser(string username, string database)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            var security = @"{""admins"":{""names"":[""%name%""],""roles"":[]},""readers"":{""names"":[""%name%""],""roles"":[]}}".Replace("%name%", username).Replace("\r\n", "");&lt;br /&gt;            var docResult = GetRequest(baseUri + "/" + database + "/_security")&lt;br /&gt;                .Put().Json().Data(security).GetResponse().GetJObject();&lt;br /&gt;            return docResult;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-7762085589298858977?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/7762085589298858977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/09/creating-database-admin-user-in-couchdb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/7762085589298858977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/7762085589298858977'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/09/creating-database-admin-user-in-couchdb.html' title='Creating Database admin user In CouchDB using LoveSeat (C#)'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-6340119505618720007</id><published>2011-08-16T05:35:00.001-07:00</published><updated>2011-08-16T05:50:49.805-07:00</updated><title type='text'>Creating Database In CouchDB using LoveSeat (C#)</title><content type='html'>Getting Started with CouchDB using Loveseat C#&lt;br /&gt;We all know that there is very limited resources to help Implementing CouchDB using c#. as far as i feel Love Seat is the best.&lt;br /&gt;&lt;br /&gt;Here are i am going to discuss very basic thing. &lt;br /&gt;How to create Database in CouchDB using Loveseat c#.net&lt;br /&gt;&lt;br /&gt;First step:&lt;br /&gt;we have to create a connection to Couchdb database.&lt;br /&gt;&lt;br /&gt; &lt;span style="font-style:italic;"&gt;CouchClient ccAdmin = new CouchClient("localhost", 5984, null, null);&lt;span style="font-weight:bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the above code i am passing username and password as null. if you have installed couch db recently then every user will be considered as admin user as long as you have created a new user.&lt;br /&gt;&lt;br /&gt;If you have username and password with you the pass them while creating couch client instance.&lt;br /&gt;&lt;br /&gt;Here in the following code i am checking for the database existence before creating it. &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Note: CouchDB is case sensitive we should not user UpperCase (Capital Letters) while creating database. ("Database1" is wrong syntax! it has to be "database1")&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;string dbname = "database1";&lt;br /&gt; if (!ccAdmin.HasDatabase(dbname))&lt;br /&gt;     {&lt;br /&gt;       ccAdmin.CreateDatabase(dbname);&lt;br /&gt;      }&lt;span style="font-weight:bold;"&gt;&lt;span style="font-weight:bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-6340119505618720007?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/6340119505618720007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/08/creating-database-in-couchdb-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/6340119505618720007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/6340119505618720007'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/08/creating-database-in-couchdb-using.html' title='Creating Database In CouchDB using LoveSeat (C#)'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-5208953968141839679</id><published>2011-08-09T07:21:00.000-07:00</published><updated>2011-08-09T07:49:47.810-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF Idataerrorinfo'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF form validations'/><category scheme='http://www.blogger.com/atom/ns#' term='validations in wpf'/><title type='text'>WPF and Silverlight Validation using IDataErrorInfo</title><content type='html'>How to validate WPF or Silverlight Form or Page..?&lt;br /&gt;Validations in wpf&lt;br /&gt;There are several ways to validate a WPF or Silverlight form and IDataError Info is the one of the interesting way to do validations. &lt;br /&gt;&lt;br /&gt;IDataErrorInfo is a part of System.dll Assembly.&lt;br /&gt;&lt;br /&gt;this interface contains couple of properties which we have to override in our implementation.  &lt;br /&gt;&lt;br /&gt;1) string Error { get; }&lt;br /&gt;&lt;br /&gt;2) string this[string columnName] { get; }&lt;br /&gt;&lt;br /&gt;out of these two properties the second property is an Index.&lt;br /&gt; (you can learn more about indexers &lt;a href="http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx"&gt;here&lt;/a&gt;: http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx)&lt;br /&gt;&lt;br /&gt;Here is a sample which will give some information about the implementation of IDataErrorInfo.&lt;br /&gt;&lt;br /&gt;Here I am creating a user Class which implements  IDataErrorInfo.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;&lt;br /&gt;public class User : ViewModelbase, IDataErrorInfo&lt;br /&gt;    {&lt;br /&gt;        private string firstName;&lt;br /&gt;&lt;br /&gt;        public string FirstName&lt;br /&gt;        {&lt;br /&gt;            get { return firstName; }&lt;br /&gt;            set { firstName = value;&lt;br /&gt;            OnPropertyChanged("FirstName");&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private string lastName;&lt;br /&gt;&lt;br /&gt;        public string LastName&lt;br /&gt;        {&lt;br /&gt;            get { return lastName; }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                lastName = value;&lt;br /&gt;                OnPropertyChanged("LastName");&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;      &lt;br /&gt;&lt;br /&gt;        #region IDataErrorInfo Members&lt;br /&gt;&lt;br /&gt;        public string Error&lt;br /&gt;        {&lt;br /&gt;            get { throw new NotImplementedException(); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public string this[string columnName]&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                string result = null;&lt;br /&gt;                if (columnName == "FirstName")&lt;br /&gt;                {&lt;br /&gt;                    if (string.IsNullOrEmpty(FirstName))&lt;br /&gt;                        result = "Please enter a First Name";&lt;br /&gt;                }&lt;br /&gt;                if (columnName == "LastName")&lt;br /&gt;                {&lt;br /&gt;                    if (string.IsNullOrEmpty(LastName))&lt;br /&gt;                        result = "Please enter a Last Name";&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                return result;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can observe the public string this[string columnName] property which contains if condition for Firstname and lastname.. when ever we there is a property changed notification then this indexer will get initiated and checks for the valid value and the value it returned will appear as error message.&lt;br /&gt;&lt;br /&gt;Implementing the following style will give error template to a text box whenever validation returns error message&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-8bmV_BCFX8I/TkFHtGwpizI/AAAAAAAAFPc/wCbJ8F-yXLg/s1600/Xaml.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 176px;" src="http://1.bp.blogspot.com/-8bmV_BCFX8I/TkFHtGwpizI/AAAAAAAAFPc/wCbJ8F-yXLg/s320/Xaml.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5638867048678918962" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-5208953968141839679?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/5208953968141839679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/08/wpf-and-silverlight-validation-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/5208953968141839679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/5208953968141839679'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/08/wpf-and-silverlight-validation-using.html' title='WPF and Silverlight Validation using IDataErrorInfo'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-8bmV_BCFX8I/TkFHtGwpizI/AAAAAAAAFPc/wCbJ8F-yXLg/s72-c/Xaml.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-6086360421257295702</id><published>2011-07-27T02:37:00.000-07:00</published><updated>2011-07-29T15:34:46.945-07:00</updated><title type='text'>What is Parallel keyword and how it works in c# 4</title><content type='html'>in this sample i am going to discuss what  Parallel.ForEach will do...&lt;br /&gt;&lt;br /&gt;Here i am creating a list of strings and using parallel foreach making a call to the method which is in server class.&lt;br /&gt; &lt;br /&gt;and in our output you can observer the order of the elements. they are not in any particular order...&lt;br /&gt;&lt;br /&gt;Because parallel foreach internally create a separate thread for each and every call. which will behave independently.. means each and every request will be handled asynchronously where Normal foreach is Synchronous behavior..&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-weight:bold;"&gt;Note:&lt;/span&gt;&lt;br /&gt; &lt;span style="font-weight:bold;"&gt;It is really tough to debug the calls that make in the Parallel.Foreach.. &lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt; List&lt;string&gt; list = new List&lt;string&gt;();&lt;br /&gt;            for (int i = 0; i &lt; 5; i++)&lt;br /&gt;            {&lt;br /&gt;                list.Add("list item" + i.ToString());&lt;br /&gt;            }&lt;br /&gt;            Server server = new Server();&lt;br /&gt;            Parallel.ForEach(list, (i) =&gt; { server.GetDetails(i); });&lt;br /&gt;            Console.Read();&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="font-style:italic;"&gt;&lt;span style="font-style:italic;"&gt; public class Server&lt;br /&gt;    {&lt;br /&gt;        public void GetDetails(dynamic item)&lt;br /&gt;        {&lt;br /&gt;            for (int i = 0; i &lt; 3; i++)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("Request :: " + i + " " + item.ToString());&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;span style="font-weight:bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;OutPut&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Request :: 0 list item4&lt;br /&gt;Request :: 1 list item4&lt;br /&gt;Request :: 2 list item4&lt;br /&gt;Request :: 0 list item1&lt;br /&gt;Request :: 1 list item1&lt;br /&gt;Request :: 0 list item2&lt;br /&gt;Request :: 1 list item2&lt;br /&gt;Request :: 2 list item2&lt;br /&gt;Request :: 0 list item3&lt;br /&gt;Request :: 1 list item3&lt;br /&gt;Request :: 2 list item3&lt;br /&gt;Request :: 0 list item0&lt;br /&gt;Request :: 1 list item0&lt;br /&gt;Request :: 2 list item0&lt;br /&gt;Request :: 2 list item1&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-6086360421257295702?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/6086360421257295702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/07/what-is-parallel-key-word-and-how-it.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/6086360421257295702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/6086360421257295702'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/07/what-is-parallel-key-word-and-how-it.html' title='What is Parallel keyword and how it works in c# 4'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-8136231337313938744</id><published>2011-07-25T07:22:00.001-07:00</published><updated>2011-07-25T09:34:15.411-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c# 4.0'/><title type='text'>How dynamic in c# 4.0 works</title><content type='html'>In this Post i will try to give an idea what "dynamic" keyword do.&lt;br /&gt;&lt;br /&gt;Have a loot at the following Program class, in the constructor of the program class i am calling StartDeveloperWork and StartDynamicWork methods by passing similar objects in the order.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="font-style:italic;"&gt;class Program&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        public Program()&lt;br /&gt;        {&lt;br /&gt;            //Case 1&lt;br /&gt;            StartDeveloperWork(new Developer());&lt;br /&gt;            StartDeveloperWork(new ASPNetDeveloper());&lt;br /&gt;            StartDeveloperWork(new WPFDeveloper());&lt;br /&gt;&lt;br /&gt;            //Case 2&lt;br /&gt;            StartDynamicWork(new Developer());&lt;br /&gt;            StartDynamicWork(new ASPNetDeveloper());&lt;br /&gt;            StartDynamicWork(new WPFDeveloper());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void StartWork(Developer d)&lt;br /&gt;        {&lt;br /&gt;            d.Work();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void StartWork(dynamic d)&lt;br /&gt;        {&lt;br /&gt;            d.Work();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    class WPFDeveloper : Developer&lt;br /&gt;    {&lt;br /&gt;        public void Work()&lt;br /&gt;        {&lt;br /&gt;            Console.Write("WPFDeveloper ");&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    class ASPNetDeveloper : Developer&lt;br /&gt;    {&lt;br /&gt;        public void Work()&lt;br /&gt;        {&lt;br /&gt;            Console.Write("ASPNetDeveloper ");&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    class Developer&lt;br /&gt;    {&lt;br /&gt;        public void Work()&lt;br /&gt;        {&lt;br /&gt;            Console.Write("Developer ");&lt;br /&gt;        }&lt;br /&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;but the out put displayed for startdeveloperwork will be &lt;br /&gt;&lt;span style="font-style:italic;"&gt;Developer &lt;br /&gt;Developer &lt;br /&gt;Developer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and out put displayed for StartDynamicWork will be&lt;br /&gt;&lt;br /&gt;Developer &lt;br /&gt;ASPNetDeveloper &lt;br /&gt;WPFDeveloper &lt;br /&gt;&lt;br /&gt;.. because we in Developer class we have not marked work method as Virtual so when we are calling with base class reference the method in the base calls will be called.&lt;br /&gt;&lt;br /&gt;in the StartDeveloperWork method we are using base class reference for calling work method.&lt;br /&gt;&lt;br /&gt;coming to StartDynamicWork we are using dynamic keywork means the type of object will be decided at runtime. so method in the passed object will be called.&lt;br /&gt;if the method is not there in the passed object then it will go to base class for the same method. if the method is not there in base class also then it will throw an target invocation exception.&lt;br /&gt;&lt;br /&gt;So be care full and make yourself clear when to use and when not  to use&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-8136231337313938744?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/8136231337313938744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/07/how-dynamic-c-40-works_25.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/8136231337313938744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/8136231337313938744'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/07/how-dynamic-c-40-works_25.html' title='How dynamic in c# 4.0 works'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-8091773423280758649</id><published>2011-07-25T06:39:00.000-07:00</published><updated>2011-09-15T07:53:29.478-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='background thread'/><category scheme='http://www.blogger.com/atom/ns#' term='Task factory'/><category scheme='http://www.blogger.com/atom/ns#' term='Multitasking In WPF'/><title type='text'>WPF: Build Responsive UI (Threading)</title><content type='html'>I am going to explain how to &lt;span style="font-weight:bold;"&gt;build responsive user Interface&lt;/span&gt;. Implementing threading in WPF.. and this post may help the people who is getting "&lt;span style="font-weight:bold;"&gt;The calling thread cannot access this object because a different thread owns it&lt;/span&gt;" exception&lt;br /&gt;&lt;br /&gt;The most frequent problem or situation wpf developers face is &lt;span style="font-weight:bold;"&gt;Blocked UI&lt;/span&gt;. &lt;br /&gt;This solution also works for "&lt;span style="font-weight:bold;"&gt;calling thread cannot access this object because a different thread owns it&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;" exception.&lt;br /&gt;when we are pooling some data to/from the server &lt;span style="font-weight:bold;"&gt;wpf UI will get hangs&lt;/span&gt; which will question the capability of WPF.&lt;br /&gt;&lt;br /&gt;here i will try to explain how to use thread to overcome this.&lt;br /&gt;&lt;br /&gt;In the following code i am creating new instance for task factory and starting a new task.&lt;br /&gt;so all the code we pass in the  factory will run in the background..&lt;br /&gt;   &lt;br /&gt; &lt;span style="font-style:italic;"&gt;TaskFactory tFactory = new TaskFactory();&lt;br /&gt;            tFactory.StartNew(() =&gt;&lt;br /&gt;            {&lt;br /&gt;                // DO YOUR SERVER CALLS or SOMETHING which you want to run in the background&lt;br /&gt;            });&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After looking the above the first question comes in mind is Can i update UI from this task or thread.?&lt;br /&gt;and the answer is NO You can't update UI from the background thread.&lt;br /&gt;for updating UI you have to take the control to the Dispatcher thread.&lt;br /&gt;some thing like this.&lt;br /&gt; &lt;br /&gt;&lt;span style="font-style:italic;"&gt;TaskFactory tFactory = new TaskFactory();&lt;br /&gt;            tFactory.StartNew(() =&gt;&lt;br /&gt;            {&lt;br /&gt;                // DO YOUR SERVER CALLS or SOMETHING which you want to run in the background&lt;br /&gt;                System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)delegate()&lt;br /&gt;                {&lt;br /&gt;                   // UI Related stuff&lt;br /&gt;                });&lt;br /&gt;            });&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;We learned how to execute a task in background and how to update UI from that thread.&lt;br /&gt;&lt;br /&gt;Now let us discuss about how to execute the task and some other code synchronously.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Consider this scenario.&lt;/span&gt;&lt;br /&gt;we have to get some data from the server and after that we have play with data.&lt;br /&gt;means our next action is completely dependent on the callback or completion of Task.&lt;br /&gt;&lt;br /&gt;in this case we can use task factory ContinueWith method like following&lt;br /&gt;&lt;br /&gt; TaskFactory tFactory = new TaskFactory();&lt;br /&gt;            tFactory.StartNew(() =&gt;&lt;br /&gt;            {&lt;br /&gt;                // DO YOUR SERVER CALLS or SOMETHING which you want to run in the background&lt;br /&gt;                System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)delegate()&lt;br /&gt;                {&lt;br /&gt;                   // UI Related stuff&lt;br /&gt;                });&lt;br /&gt;            }).ContinueWith(t =&gt;&lt;br /&gt;             {&lt;br /&gt;                 if (t.IsFaulted)&lt;br /&gt;                 {&lt;br /&gt;                     throw t.Exception;&lt;br /&gt;                 }&lt;br /&gt;                 System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)delegate()&lt;br /&gt;                 {&lt;br /&gt;                     // do some thig after task completion&lt;br /&gt;                 });&lt;br /&gt;             });&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now i am putting all the three scenario in one place with simple example&lt;br /&gt;&lt;br /&gt; &lt;span style="font-style:italic;"&gt;ObservableCollection&lt;string&gt; images = new ObservableCollection&lt;string&gt;();&lt;br /&gt;            TaskFactory tFactory = new TaskFactory();&lt;br /&gt;            tFactory.StartNew(() =&gt;&lt;br /&gt;            {&lt;br /&gt;                for (int i = 0; i &lt; 50; i++)&lt;br /&gt;                {&lt;br /&gt;                    //GET IMAGE Path FROM SERVER&lt;br /&gt;                    System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)delegate()&lt;br /&gt;                    {&lt;br /&gt;                        // UPDATE PROGRESS BAR IN UI&lt;br /&gt;                    });&lt;br /&gt;&lt;br /&gt;                    images.Add(("&lt;image path&gt;");&lt;br /&gt;                }&lt;br /&gt;            &lt;br /&gt;            }).ContinueWith(t =&gt;&lt;br /&gt;             {&lt;br /&gt;                 if (t.IsFaulted)&lt;br /&gt;                 {&lt;br /&gt;                     // EXCEPTION IF THREAD IS FAULT&lt;br /&gt;                     throw t.Exception;&lt;br /&gt;                 }&lt;br /&gt;                 System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)delegate()&lt;br /&gt;                 {&lt;br /&gt;                     //PROCESS IMAGES AND DISPLAY&lt;br /&gt;                 });&lt;br /&gt;             });&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-8091773423280758649?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/8091773423280758649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/07/wpf-build-more-responsive-ui.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/8091773423280758649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/8091773423280758649'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2011/07/wpf-build-more-responsive-ui.html' title='WPF: Build Responsive UI (Threading)'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-7356194112243544230</id><published>2010-01-27T03:30:00.000-08:00</published><updated>2010-01-27T04:01:54.303-08:00</updated><title type='text'>.net 4.0, wpf 4  Translation Transform Flickering. Solution.</title><content type='html'>Translation manipulation not working.?&lt;br /&gt;&lt;br /&gt;TranslateTransform issue in wpf 4.0. &lt;br /&gt;&lt;br /&gt;There is an issue with DeltaManipulation in .net 4.0 (Till RC 1).&lt;br /&gt;&lt;br /&gt;e.DeltaManipulation behaves weired it always returns unexpected values.&lt;br /&gt;&lt;br /&gt;But the issue is only with e.DeltaManipulation but not with e.ManipulationOrigin and e.CumulativeManipulation.&lt;br /&gt;With the Cumalative manipulation or with manipulation orgin we can easily get the delta manipulation value.&lt;br /&gt;while starting manipulation take the start position and subtract the value from the Cumalativemanipulation. we will get delta value.&lt;br /&gt;&lt;br /&gt;Here is the the sample Code using C#&lt;br /&gt;&lt;br /&gt;&lt;!-- XAML --&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_cEm8FKNxl98/S2An2g-0IxI/AAAAAAAAEMk/13gSf5MOIdw/s1600-h/XamlCode.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 62px;" src="http://1.bp.blogspot.com/_cEm8FKNxl98/S2An2g-0IxI/AAAAAAAAEMk/13gSf5MOIdw/s320/XamlCode.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5431384968128635666" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- XAML.CS --&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Windows;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using System.Windows.Data;&lt;br /&gt;using System.Windows.Documents;&lt;br /&gt;using System.Windows.Input;&lt;br /&gt;using System.Windows.Media;&lt;br /&gt;using System.Windows.Media.Imaging;&lt;br /&gt;using System.Windows.Navigation;&lt;br /&gt;using System.Windows.Shapes;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;&lt;br /&gt;namespace ManipulationSample&lt;br /&gt;{&lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;    /// Interaction logic for MainWindow.xaml&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;    public partial class MainWindow : Window&lt;br /&gt;    {&lt;br /&gt;        MatrixTransform tg = new MatrixTransform();&lt;br /&gt;        public MainWindow()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            Img.RenderTransform = tg;   &lt;br /&gt;        }&lt;br /&gt;        Point StartPosition = new Point();&lt;br /&gt;        private void Canvas_ManipulationStarted(object sender, ManipulationStartedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            StartPosition = e.ManipulationOrigin;&lt;br /&gt;            Debug.WriteLine("StartPosition::::::: " + StartPosition);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Canvas_ManipulationStarting(object sender, ManipulationStartingEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            e.ManipulationContainer = Img;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Canvas_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;br /&gt;            var matrix = ((MatrixTransform)Img.RenderTransform).Matrix;&lt;br /&gt;            matrix.Translate((e.ManipulationOrigin.X - StartPosition.X), (e.ManipulationOrigin.Y - StartPosition.Y));&lt;br /&gt;            ((MatrixTransform)Img.RenderTransform).Matrix = matrix;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-7356194112243544230?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/7356194112243544230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2010/01/net-40-translation-transform-flickering.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/7356194112243544230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/7356194112243544230'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2010/01/net-40-translation-transform-flickering.html' title='.net 4.0, wpf 4  Translation Transform Flickering. Solution.'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_cEm8FKNxl98/S2An2g-0IxI/AAAAAAAAEMk/13gSf5MOIdw/s72-c/XamlCode.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-3702430894091892415</id><published>2009-05-11T05:21:00.000-07:00</published><updated>2009-05-11T05:23:07.793-07:00</updated><title type='text'>SilverLight: get Path Geomatery Figures from PathGeometary object</title><content type='html'>/// pg is the pathgeomatery Object.&lt;br /&gt;/// Tested on silverlight 2.0&lt;br /&gt;string pathdata = "";&lt;br /&gt;foreach (PathFigure item in pg.Figures)&lt;br /&gt;{&lt;br /&gt;pathdata = "M " + item.StartPoint.X + "," + item.StartPoint.Y;&lt;br /&gt;foreach (PathSegment item1 in item.Segments)&lt;br /&gt;{&lt;br /&gt;if (item1.GetType() == typeof(LineSegment))&lt;br /&gt;{&lt;br /&gt;pathdata = pathdata + "L " + ((LineSegment)item1).Point.X + "," + ((LineSegment)item1).Point.Y;&lt;br /&gt;}&lt;br /&gt;else if (item1.GetType() == typeof(BezierSegment))&lt;br /&gt;{&lt;br /&gt;pathdata = pathdata + "C " + ((BezierSegment)item1).Point1.X + "," + ((BezierSegment)item1).Point1.Y + " " + ((BezierSegment)item1).Point2.X + "," + ((BezierSegment)item1).Point2.Y + " " + ((BezierSegment)item1).Point3.X + "," + ((BezierSegment)item1).Point3.Y;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;if (item.IsClosed)&lt;br /&gt;pathdata = pathdata + "Z";&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-3702430894091892415?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/3702430894091892415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2009/05/silverlight-get-path-geomatery-figures.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/3702430894091892415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/3702430894091892415'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2009/05/silverlight-get-path-geomatery-figures.html' title='SilverLight: get Path Geomatery Figures from PathGeometary object'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5288223254146567013.post-7694305568725304164</id><published>2009-05-11T04:33:00.000-07:00</published><updated>2011-08-26T04:32:47.648-07:00</updated><title type='text'>Creating A SilverLight Path Geometry from data string. creating path dynamically</title><content type='html'>Hi&lt;br /&gt;here is the code for creating a SilverLight path Geometry dynamically.&lt;br /&gt;or creating a SilverLight path from a string.&lt;br /&gt;Just paste below method in a new class or in existing class and it will be ready to use.&lt;br /&gt;you can find a sample code to use this functions at bottom of the method.&lt;br /&gt;&lt;br /&gt;/// Method tested with SilverLight 2.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// this method will generates path with the data string&lt;br /&gt;public PathGeometry getPathGeometry(string data)&lt;br /&gt;{&lt;br /&gt;PathGeometry pg = new PathGeometry();&lt;br /&gt;PathSegmentCollection psc = new PathSegmentCollection();&lt;br /&gt;PathFigure pf = new PathFigure();&lt;br /&gt;PathFigureCollection pfc = new PathFigureCollection();&lt;br /&gt;data= data.Replace("M "," M").Replace("C "," C").Replace("L "," L");&lt;br /&gt;string[] str = data.Split(' ');&lt;br /&gt;for (int i = 0; i &lt; str.Length; i++)&lt;br /&gt;{&lt;br /&gt;if (str[i].StartsWith("C") or  str[i].StartsWith("c"))&lt;br /&gt;{&lt;br /&gt;string[] item = str[i].Split(',');&lt;br /&gt;string[] item1 = str[i + 1].Split(',');&lt;br /&gt;string[] item2 = str[i + 2].Split(',');&lt;br /&gt;BezierSegment bs = new BezierSegment();&lt;br /&gt;bs.Point1 = new Point(double.Parse(item[0].Substring(1)), double.Parse(item[1]));&lt;br /&gt;bs.Point2 = new Point(double.Parse(item1[0]), double.Parse(item1[1]));&lt;br /&gt;bs.Point3 = new Point(double.Parse(item2[0]), double.Parse(item2[1]));&lt;br /&gt;i += 2;&lt;br /&gt;psc.Add(bs);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;if (str[i].StartsWith("L") or str[i].StartsWith("l"))&lt;br /&gt;{&lt;br /&gt;string[] item = str[i].Split(',');&lt;br /&gt;LineSegment ls = new LineSegment();&lt;br /&gt;ls.Point = new Point(double.Parse(item[0].Substring(1)), double.Parse(item[1]));&lt;br /&gt;psc.Add(ls);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;if (str[i].StartsWith("M") or str[i].StartsWith("m"))&lt;br /&gt;{&lt;br /&gt;string[] item = str[i].Split(',');&lt;br /&gt;pf.StartPoint = new Point(double.Parse(item[0].Substring(1)), double.Parse(item[1]));&lt;br /&gt;}&lt;br /&gt;else if (str[i].StartsWith("z") or str[i].StartsWith("Z"))&lt;br /&gt;{&lt;br /&gt;pf.IsClosed = true;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;pf.Segments = psc;&lt;br /&gt;pfc.Add(pf);&lt;br /&gt;pg.Figures = pfc;&lt;br /&gt;return pg;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;///// End of Method&lt;br /&gt;Sample Code for calling method&lt;br /&gt;Path path = new Path();&lt;br /&gt;string str = " F1 M 933.291,430.505C 924.367,415.673 923.007,387.822 922.503,370.604C 921.343,331.31 944.994,317.76 975.999,296.994L 949.334,299.957C 938.729,302.545 930.572,309.925 920.255,313.368C 901.85,319.521 886.504,313.062 870.896,303.53C 850.12,290.842 831.457,270.65 815.107,251.462C 806.279,241.101 798.257,221.598 781.986,226.017C 767.327,229.99 760.199,246.869 743.058,244.012C 737.559,227.262 741.368,204.78 739.591,187.029C 738.108,172.136 733.986,158.933 733.996,143.736C 734.003,128.417 734.091,113.088 733.996,97.7689C 733.909,83.5475 730.302,82.6582 716.114,86.0475C 687.558,92.8796 663.68,115.232 634.418,119.337C 622.391,121.028 598.323,121.184 603.745,103.642C 603.745,103.642 547.667,116.478 522.623,101.969L 397.73,43.1915C 374.54,33.5875 352.799,21.5236 330.186,10.7568C 315.067,3.55951 298.84,3.50623 282.684,6.54358C 268.628,9.18353 252.14,8.36884 238.73,13.0222C 227.932,16.7648 225.711,27.0569 220.839,35.6369C 204.622,64.1582 184.474,89.9609 163.49,115.642C 143.3,140.356 124.747,161.949 100.268,182.977C 76.4618,203.437 58.0045,230.722 39.6698,256.062C 27.9845,272.228 10.5298,295.73 5.62447,315.546C 1.21381,333.368 7.65381,345.95 16.7778,360.225C 30.9738,382.42 52.4365,394.917 74.4578,408.658C 108.356,429.826 144.964,432.43 182.619,439.202C 194.226,441.284 201.93,444.466 212.456,450.234C 228.9,459.261 246.18,466.181 262.031,476.002C 277.378,485.518 288.175,498.328 306.771,498.502C 331.423,498.729 342.159,498.364 359.554,517.221C 368.632,527.06 372.859,537.585 380.38,548.114C 395.159,568.82 409.076,590.689 426.295,609.442C 440.326,624.728 467.967,633.601 487.652,636.902C 505.622,639.908 521.979,632.736 535.859,620.806C 545.402,612.606 552.478,602.246 557.978,591.161C 561.915,583.213 564.966,568.085 572.399,564.296C 578.046,561.41 595.117,563.91 601.338,564.312C 612.171,565.009 621.722,568.994 632.552,569.976C 651.071,571.65 654.679,567.992 668.187,558.989C 681.275,550.254 697.746,547.268 711.451,538.109C 733.726,523.208 751.861,501.273 773.035,484.254C 795.099,466.53 815.65,437.337 845.207,434.924C 871.813,432.754 933.291,430.505 933.291,430.505 Z";&lt;br /&gt;path.Data = getPathGeometry(str);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5288223254146567013-7694305568725304164?l=bathinenivenkatesh.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bathinenivenkatesh.blogspot.com/feeds/7694305568725304164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2009/05/creating-path-geometry-from-data-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/7694305568725304164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5288223254146567013/posts/default/7694305568725304164'/><link rel='alternate' type='text/html' href='http://bathinenivenkatesh.blogspot.com/2009/05/creating-path-geometry-from-data-string.html' title='Creating A SilverLight Path Geometry from data string. creating path dynamically'/><author><name>Bathineni Venkatesh</name><uri>http://www.blogger.com/profile/11894716499536167676</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_cEm8FKNxl98/SggZ3vZn9gI/AAAAAAAACx4/Vl89Y-rOoP4/S220/IMG_2532.jpg'/></author><thr:total>0</thr:total></entry></feed>
