<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">FarsiLibrary - SeeSharp</title>
  <icon>http://www.hightech.ir/favicon.ico</icon>
  <logo>http://www.hightech.ir/favicon.png</logo>
  <updated>2010-02-26T08:57:00</updated>
  <subtitle type="html">A C# development blog</subtitle>
  <id>http://www.hightech.ir/tags/farsilibrary/atom</id>
  <link rel="alternate" type="text/html" hreflang="en" href="/tags/farsilibrary/atom"/>
  <link rel="self" type="application/atom+xml" href="http://www.hightech.ir/Tags/FarsiLibrary/ATOM"/>
  <generator uri="http://oxite.net" version="1.0">Oxite</generator>
  <entry>
    <title type="html">PersianCalendar support for DevExpress</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/PersianCalendar-Support-For-DevExpress"/>
    <id>http://www.hightech.ir/SeeSharp/PersianCalendar-Support-For-DevExpress</id>
    <updated>2010-02-27T07:43:28.787</updated>
    <published>2010-02-26T08:57:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="FarsiLibrary" />
    <category term="WPF" />
    <category term="DevExpress" />
    <content type="html" xml:lang="en">
      &lt;p&gt;
	Creating Line of Business applications using &lt;a href=&quot;http://www.devexpress.com/Products/NET/Controls/WPF/Grid/&quot;&gt;DevExpress WPF controls&lt;/a&gt; is just a breeze. The actual application is nice looking too! Since there are a couple of skins available and the good thing is the skin also changes the look and feel of standard WPF controls!&lt;/p&gt;
&lt;p&gt;
	I&amp;#39;ve used &lt;a href=&quot;http://github.com/HEskandari/FarsiLibrary&quot;&gt;my calendar library&lt;/a&gt; to develop a fully localizable solution. These controls support &lt;a href=&quot;http://en.wikipedia.org/wiki/Gregorian_calendar&quot;&gt;Gregorian&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Islamic_calendar&quot;&gt;Hijri&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Iranian_calendar&quot;&gt;Persian&lt;/a&gt; calendars so multicultural application development would be seamless, but the look and feel of my controls were a lot different than the ones provided by DevExpress. On the other hand, DevExpress only supports Gregorian calendar! So I needed to apply look and feel of DevExpress to my controls. It goes without saying that you can open the controls in Expression Blend and give it a style that mimics DevExpress look and feel, but that is not easy to do.&lt;/p&gt;
&lt;p&gt;
	DevExpress provides a PopupEditBase control that can be used to display any control as a Popup. That seemed to be a good choice and it was easy to create a new control all in xaml markup:&lt;/p&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;
&amp;lt;Window x:Class=&amp;quot;DXCustomEditor.MainWindow&amp;quot;
        xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;
        xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot; 
        xmlns:dxe=&amp;quot;http://schemas.devexpress.com/winfx/2008/xaml/editors&amp;quot; 
        xmlns:fx=&amp;quot;http://schemas.hightech.ir/wpf/2008/FarsiLibrary&amp;quot;
        Title=&amp;quot;DX Editors&amp;quot; Height=&amp;quot;350&amp;quot; Width=&amp;quot;525&amp;quot;
        xmlns:loc=&amp;quot;clr-namespace:DXCustomEditor&amp;quot;&amp;gt;
    &amp;lt;Window.Resources&amp;gt;
        &amp;lt;loc:DateConverter x:Key=&amp;quot;DateConverter&amp;quot;/&amp;gt;
        &amp;lt;ControlTemplate x:Key=&amp;quot;DatePickerTemplate&amp;quot;&amp;gt;
            &amp;lt;fx:FXMonthView SelectedDateTime=&amp;quot;{Binding Path=(dxe:BaseEdit.OwnerEdit).EditValue, Mode=TwoWay, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource DateConverter}}&amp;quot;/&amp;gt;
        &amp;lt;/ControlTemplate&amp;gt;
    &amp;lt;/Window.Resources&amp;gt;
    &amp;lt;StackPanel Margin=&amp;quot;10&amp;quot;&amp;gt;
        &amp;lt;dxe:PopupBaseEdit IsTextEditable=&amp;quot;False&amp;quot; PopupContentTemplate=&amp;quot;{StaticResource ResourceKey=DatePickerTemplate}&amp;quot; /&amp;gt;
    &amp;lt;/StackPanel&amp;gt;
&amp;lt;/Window&amp;gt;
&lt;/pre&gt;
&lt;p&gt;
	The outcome is pretty good: seamless calendar support and look and feel.&lt;/p&gt;
&lt;p style=&quot;text-align: center;&quot;&gt;
	&lt;img alt=&quot;&quot; src=&quot;http://www.hightech.ir/Images/BlogPics/ePub-Screenshot-s.png&quot; /&gt;&lt;/p&gt;
    </content>
  </entry>
  <entry>
    <title type="html">BiDi applications with Silverlight 4</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/Silverlight-Four-With-Right-To-Left-Support"/>
    <id>http://www.hightech.ir/SeeSharp/Silverlight-Four-With-Right-To-Left-Support</id>
    <updated>2009-11-26T10:46:18.97</updated>
    <published>2009-11-25T14:15:57</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="Silverlight" />
    <category term="FarsiLibrary" />
    <category term="RightToLeft" />
    <content type="html" xml:lang="en">
      &lt;p&gt;I started checking out the new Silverlight 4 Beta this week and the most important feature (for me) added to this release : FlowDirection. If you’re not a WPF guy, this is the equivalent of RightToLeft in WinForm world, just recently added to Silverlight. If this works the way the same feature in WPF works, all custom controls built in this platform will automagically have correct RightToLeft behavior, “Almost” without any additional code from component vendor / developer. Sounds too good to be true, but it is.&lt;/p&gt;

&lt;p&gt;To test how this works, we need a Silverlight 4 control first. Well, look no further! AgDataGrid from DevExpress is both free and open-source! Register and grab your version from &lt;a href=&quot;http://www.devexpress.com/Products/NET/Controls/Silverlight/Register/
&quot;&gt;here&lt;/a&gt;. Should you need to see some demos of this control's features go &lt;a href=&quot;http://demos.devexpress.com/AgDataGridDemos/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The build is for latest released version of Silverlight 3, so you need to compile it against Silverlight 4 runtime. Open the solution and change the framework version to SL 4 and build it. That’s it. &lt;/p&gt;

&lt;p&gt;Now a Silverlight Application and remember to select “Silverlight 4” runtime when Visual Studio asks which runtime version to use. Add reference to assemblies you just built and add a agDataGrid instance to your page:&lt;/p&gt;

&lt;pre class=&quot;brush:c-sharp&quot;&gt;
&amp;lt;dg:AgDataGrid x:Name=&quot;grid&quot; FlowDirection=&quot;RightToLeft&quot; 
               ShowGroupPanel=&quot;Visible&quot;&amp;gt;
   &amp;lt;dg:AgDataGrid.Columns&amp;gt;
        &amp;lt;dg:AgDataGridTextColumn x:Name=&quot;colFirstname&quot; FieldName=&quot;Firstname&quot; HeaderContent=&quot;نام&quot; /&amp;gt;
        &amp;lt;dg:AgDataGridTextColumn x:Name=&quot;colLastname&quot; FieldName=&quot;Lastname&quot; HeaderContent=&quot;نام خانوادگی&quot; /&amp;gt;
        &amp;lt;dg:AgDataGridColumn x:Name=&quot;colDateOfBirth&quot; FieldName=&quot;DateOfBirth&quot; HeaderContent=&quot;تاریخ تولد&quot;/&amp;gt;
    &amp;lt;/dg:AgDataGrid.Columns&amp;gt;
&amp;lt;/dg:AgDataGrid&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Note the new FlowDirection property on AgDataGrid is added automatically just by compiling it against SL 4.&lt;/p&gt;

&lt;p&gt;To make it a better example, let’s add some more sugar to the pot. To localize the GroupPanel text, let’s use a DataTemplate. I also needed to display the DateOfBirth values in PersianCalendar, so I’m going to create a converter for that. The final xaml looks like this:&lt;/p&gt;

&lt;pre class=&quot;brush:xml&quot;&gt;
&amp;lt;UserControl.Resources&amp;gt;

    &amp;lt;cnv:PersianDateConverter x:Key=&quot;DefaultConverter&quot; /&amp;gt;

    &amp;lt;DataTemplate x:Key=&quot;DateTemplate&quot;&amp;gt;
        &amp;lt;TextBlock Text=&quot;{Binding Converter={StaticResource DefaultConverter}}&quot; /&amp;gt;
    &amp;lt;/DataTemplate&amp;gt;

    &amp;lt;DataTemplate x:Key=&quot;GroupTemplate&quot;&amp;gt;
        &amp;lt;TextBlock Text=&quot;برای ایجاد یک گروه ، یک ستون را به اینجا بکشید&quot; Foreground=&quot;White&quot; Margin=&quot;15,11,0,11&quot;/&amp;gt;
    &amp;lt;/DataTemplate&amp;gt;
&amp;lt;/UserControl.Resources&amp;gt;

&amp;lt;dg:AgDataGrid x:Name=&quot;grid&quot; FlowDirection=&quot;RightToLeft&quot; 
               ShowGroupPanel=&quot;Visible&quot;
               EmptyGroupPanelTemplate=&quot;{Binding Source={StaticResource GroupTemplate}}&quot;&amp;gt;
   &amp;lt;dg:AgDataGrid.Columns&amp;gt;
        &amp;lt;dg:AgDataGridTextColumn x:Name=&quot;colFirstname&quot; FieldName=&quot;Firstname&quot; HeaderContent=&quot;نام&quot; /&amp;gt;
        &amp;lt;dg:AgDataGridTextColumn x:Name=&quot;colLastname&quot; FieldName=&quot;Lastname&quot; HeaderContent=&quot;نام خانوادگی&quot; /&amp;gt;
        &amp;lt;dg:AgDataGridColumn x:Name=&quot;colDateOfBirth&quot; FieldName=&quot;DateOfBirth&quot; HeaderContent=&quot;تاریخ تولد&quot; CellDisplayTemplate=&quot;{StaticResource DateTemplate}&quot; /&amp;gt;
    &amp;lt;/dg:AgDataGrid.Columns&amp;gt;
&amp;lt;/dg:AgDataGrid&gt;&amp;gt;

&lt;/pre&gt;

&lt;p&gt;Unfortunately, unlike full version of .NET Framework, in beta version of Silverlight 4, there’s no PersianCalendar class! I’m not sure about the justification SL team has made in order to exclude this class, but I hope they’ll include it in the final version. I’ve opened a thread &lt;a href=&quot;http://betaforums.silverlight.net/forums/t/145947.aspx&quot;&gt;here&lt;/a&gt;, requesting this calendar to be added to SL 4, you may want to follow it up.&lt;/p&gt;

&lt;p&gt;For now, to do the date conversion “sans” PersianCalendar, I’m going to use my old FarsiLibrary project, now supporting with Silverlight. It is in fact the same projects that existed for WinForm and WPF, now built against Silverlight. You can get it here if you’re interested.
  &lt;br /&gt;

  &lt;br /&gt;Back to work, the date converted looks like this:&lt;/p&gt;

&lt;pre class=&quot;brush:c-sharp&quot;&gt;
public class PersianDateConverter : IValueConverter 
{ 
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
        var cell = (AgDataGridCellData) value; 

        if (cell.CellValue == null) 
            return null; 

        var date = DateTime.Parse(cell.CellValue.ToString()); 
        var converted = FarsiLibrary.Utils.PersianDateConverter.ToPersianDate(date); 

        return converted.ToString(&quot;D&quot;); 
    } 

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
        throw new InvalidOperationException(&quot;one way conversion&quot;); 
    } 
}
&lt;/pre&gt;

&lt;p&gt;…and here’s the output.&lt;/p&gt;

&lt;div class=&quot;center&quot;&gt;&lt;img src=&quot;/Images/BlogPics/SL_RTL_AgDataGrid.png&quot;/&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;

&lt;p&gt;You can get the sources of this demo from &lt;a href=&quot;http://cid-4962b6ceabc2cbd7.skydrive.live.com/self.aspx/BlogFiles/agDataGridDemo.zip&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
    </content>
  </entry>
  <entry>
    <title type="html">Dynamically Generated Images with ASP.NET MVC</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/dynamically-generated-images-with"/>
    <id>http://www.hightech.ir/SeeSharp/dynamically-generated-images-with</id>
    <updated>2009-10-18T13:39:47.257</updated>
    <published>2009-04-26T15:57:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="ASPNETMVC" />
    <category term="FarsiLibrary" />
    <category term="Calendars" />
    <content type="html" xml:lang="en">
      &lt;p&gt;For a site I'm working on using ASP.NET MVC, I intended to place a Date badge beside the blog and news posts I'm writing. Since in ASP.NET MVC there's no notion of custom controls (well, at least not like in WebForms) you'll have to do this manually, but as it turned out it was pretty easy to do.&lt;/p&gt;

&lt;p&gt;What I needed to do was to convert a Date instance, e.g. 04.23.2009 to a user friendly calendar icon like this one:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/_Z5KTIfnfuNs/SfRPHgU55rI/AAAAAAAAAN0/Vh0wfwsvIow/s1600-h/CalendarIcon3.png&quot;&gt;&lt;img style=&quot;border-width: 0px; display: inline;&quot; title=&quot;CalendarIcon&quot; alt=&quot;CalendarIcon&quot; src=&quot;http://lh5.ggpht.com/_Z5KTIfnfuNs/SfRPJsWuV5I/AAAAAAAAAN4/LFz8ONgu5ko/CalendarIcon_thumb1.png?imgmax=800&quot; width=&quot;46&quot; border=&quot;0&quot; height=&quot;51&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've seen blogs and site using different icon for each day of the month or a similar trick to do this, but why not actually render it using Graphics API and a picture?&lt;/p&gt;

&lt;p&gt;The first step was to decide what should be returned in you Controller's action method, as the action result? Since there's nothing that returns an Image as the result, let's create one:&lt;/p&gt;

&lt;pre class=&quot;brush:c-sharp&quot;&gt;
public class ImageResult : ActionResult
{
  public Image Image
  {
      get; set;
  }

  public ImageFormat ImageFormat
  {
      get; set;
  }

  private static Dictionary&amp;lt;ImageFormat, string&amp;gt; FormatMap
  {
      get; set;
  }

  static ImageResult()
  {
      CreateContentTypeMap();
  }

  public override void ExecuteResult(ControllerContext context)
  {
      if (Image == null) throw new ArgumentNullException(&quot;Image&quot;);
      if (ImageFormat == null) throw new ArgumentNullException(&quot;ImageFormat&quot;);

      context.HttpContext.Response.Clear();
      context.HttpContext.Response.ContentType = FormatMap[ImageFormat];

      Image.Save(context.HttpContext.Response.OutputStream, ImageFormat);
  }

  private static void CreateContentTypeMap()
  {
      FormatMap = new Dictionary&amp;lt;ImageFormat, string&amp;gt;
      {
          { ImageFormat.Bmp,  &quot;image/bmp&quot;                },
          { ImageFormat.Gif,  &quot;image/gif&quot;                },
          { ImageFormat.Icon, &quot;image/vnd.microsoft.icon&quot; },
          { ImageFormat.Jpeg, &quot;image/Jpeg&quot;               },
          { ImageFormat.Png,  &quot;image/png&quot;                },
          { ImageFormat.Tiff, &quot;image/tiff&quot;               },
          { ImageFormat.Wmf,  &quot;image/wmf&quot;                }
      };
  }
}
&lt;/pre&gt;

Pretty easy, ha? You just need to specify the image and the format and it is rendered to the HttpContext as an image. The controller action to render the text would something like this:&lt;br /&gt;

&lt;pre class=&quot;brush:c-sharp&quot;&gt;
public ActionResult GetCalendarBadge(DateTime displayDate)
{
  Graphics graphics = ?;
  Bitmap bmp = ?;

  //Draw using graphics

  //Direct the output to the bitmap

  return new ImageResult { Image = bmp, ImageFormat = ImageFormat.Png };
}
&lt;/pre&gt;

...and on the view:&lt;br /&gt;

&lt;pre class=&quot;brush:c-sharp&quot;&gt;
&amp;lt;% foreach(var item in this.Model.News) %&amp;gt;
     &amp;lt;%= Html.Image&amp;lt;NewsController&amp;gt;(o =&amp;gt; o.GetCalendarBadge(item.DisplayDate), 100, 100) %&amp;gt;
&amp;lt;% } %&amp;gt;
&lt;/pre&gt;

&lt;br /&gt;
&lt;a href=&quot;http://lh6.ggpht.com/_Z5KTIfnfuNs/SfRPL2NGqZI/AAAAAAAAAN8/SLmInKZkrKA/s1600-h/Calendar%5B4%5D.png&quot;&gt;&lt;img style=&quot;border: 0px none ; margin: 0px 15px 0px 0px; display: inline;&quot; title=&quot;Calendar&quot; alt=&quot;Calendar&quot; src=&quot;http://lh6.ggpht.com/_Z5KTIfnfuNs/SfRPN0r2QLI/AAAAAAAAAOA/eN7vVPK8XTY/Calendar_thumb%5B2%5D.png?imgmax=800&quot; width=&quot;90&quot; align=&quot;left&quot; border=&quot;0&quot; height=&quot;83&quot; /&gt;&lt;/a&gt;Now, to make things easier, le's use an existing bitmap as our canvas and just draw the values on it. To do this, add an existing image to your project and load it. The rest is just GDI API that renders the date values according to user's Cultural setting.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;

&lt;pre class=&quot;brush:c-sharp&quot;&gt;
public ActionResult GetCalendarBadge(DateTime displayDate)
{
  var bmp = Images.Calendar;
  var g = Graphics.FromImage(bmp);

  using (var genericFormat = GetStringFormat())
  {
      var yearRect = new Rectangle(24, 13, 40, 15);
      var dayOfMonthRect = new Rectangle(10, 29, 70, 44);
      var dayNameRect = new Rectangle(10, 30, 70, 10);
      var monthNameRect = new Rectangle(10, 61, 70, 10);

      using(var headerFont = new Font(&quot;Tahoma&quot;, 7.5f, FontStyle.Regular))
      using(var footerFont = new Font(&quot;Tahoma&quot;, 7.5f, FontStyle.Regular))
      using (var dayFont = new Font(&quot;Tahoma&quot;, 14, FontStyle.Bold))
      {
          var day = CurrentCulture.Calendar.GetDayOfMonth(displayDate).ToString();
          var month = CurrentCulture.Calendar.GetMonth(displayDate);
          var year = CurrentCulture.Calendar.GetYear(displayDate).ToString();
        
          var weekDay = CurrentCulture.Calendar.GetDayOfWeek(displayDate);
          var dayName = CurrentCulture.DateTimeFormat.GetDayName(weekDay);
          var monthName = CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month);
        
          g.DrawString(year, headerFont, Brushes.White, yearRect, genericFormat);
          g.DrawString(day, dayFont, Brushes.Black, dayOfMonthRect, genericFormat);
          g.DrawString(dayName, footerFont, Brushes.Black, dayNameRect, genericFormat);
          g.DrawString(monthName, footerFont, Brushes.Black, monthNameRect, genericFormat);
      }
  }

  return new ImageResult { Image = bmp, ImageFormat = ImageFormat.Png };
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh6.ggpht.com/_Z5KTIfnfuNs/SfRPQPntsmI/AAAAAAAAAOE/gz3ScPNikS0/s1600-h/CalendarBadge%5B14%5D.png&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline; margin-left: 0px; margin-right: 0px;&quot; title=&quot;CalendarBadge&quot; alt=&quot;CalendarBadge&quot; src=&quot;http://lh4.ggpht.com/_Z5KTIfnfuNs/SfRPUGljIaI/AAAAAAAAAOI/ytgRZXKpubI/CalendarBadge_thumb%5B12%5D.png?imgmax=800&quot; width=&quot;436&quot; border=&quot;0&quot; height=&quot;244&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;Note that CurrentCulture property returns the running user's CultureInfo which will help 'Translating' the date value correctly for different Cultures. What we achieved is a nice calendar badge with render date values and it is not even constrained to our Canvas size. Hope this helps.
    </content>
  </entry>
  <entry>
    <title type="html">FarsiLibrary 2.1 Released</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/farsilibrary-21-released"/>
    <id>http://www.hightech.ir/SeeSharp/farsilibrary-21-released</id>
    <updated>2009-10-18T14:28:31.693</updated>
    <published>2009-03-16T16:19:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="FarsiLibrary" />
    <content type="html" xml:lang="en">
      &lt;p&gt;Finally the 2.1 version of FarsiLibrary is released. Here are the changes made into this version:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;- &lt;font color=&quot;#008000&quot;&gt;&lt;strong&gt;Fixed&lt;/strong&gt;&lt;/font&gt; : Rendering of controls in non-official themes or when a 3rd party windows skinning (e.g. WindowsBlinds) is installed.    &lt;br /&gt;- &lt;font color=&quot;#008000&quot;&gt;&lt;strong&gt;Fixed&lt;/strong&gt;&lt;/font&gt; : Problem when setting SelectedDateTime property of FXDatePicker control to null value.    &lt;br /&gt;- &lt;font color=&quot;#008000&quot;&gt;&lt;strong&gt;Fixed&lt;/strong&gt;&lt;/font&gt; : Painting of FADatePicker in readonly mode when Readonly property is set fixed.    &lt;br /&gt;- &lt;font color=&quot;#008000&quot;&gt;&lt;strong&gt;Fixed&lt;/strong&gt;&lt;/font&gt; : Problem of setting ForeColor and BackColor in FADatePicker    &lt;br /&gt;- &lt;font color=&quot;#008000&quot;&gt;&lt;strong&gt;Fixed&lt;/strong&gt;&lt;/font&gt; : Certain usage of WinForms control resulted wrong display of Week Of Day in header part of the FAMonthView.    &lt;br /&gt;- &lt;font color=&quot;#008000&quot;&gt;&lt;strong&gt;Fixed&lt;/strong&gt;&lt;/font&gt; : Certain usage of FAMonthView resulted in wrong displaying of date when culture is invariant.    &lt;br /&gt;    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : Methods SetTodayDate and SetEmptyDate added to FXDatePicker and FXMonthView which lets you call the code that represents Today and Empty buttons clicks respectively.    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : PersianCultureInfo which is a FA-IR Culture with correct PersianCalendar and DateTimeFormatInfo.    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : PersianDateTimeFormatInfo that represents datetime formatting information for FA-IR culture.    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : DateTimeExtensions to help convert between PersianDate and DateTime instances via extension methods.    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : XmlnsDefinition is added to WPF namespaces. You can reference the controls assembly with &lt;a href=&quot;http://schemas.hightech.ir/wpf/2008/FarsiLibrary&quot;&gt;http://schemas.hightech.ir/wpf/2008/FarsiLibrary&lt;/a&gt; namespace.    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : Methods to add / remove validation errors on BaseControl.    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : PersianDateValueConverter which can be used in WPF applications to convert strings representing DateTime to their PersianDate equivalant.    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : WPF Demo to show usage of custom date converters.    &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : Ability to show and hide Today and Empty buttons on FAMonthView.     &lt;br /&gt;- &lt;font color=&quot;#0080ff&quot;&gt;&lt;strong&gt;Added&lt;/strong&gt;&lt;/font&gt; : VisualStudio designer for WPF and actions for WinForm controls is added.    &lt;br /&gt;    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : Localization of WPF controls are using mechanism like WinForm controls (using StringIDs). Redundant .resx files are removed.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : Merged WinForm and WPF controls into one solution.     &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : ValueValidatingEventArgs now passes HasErrors property of the control when raising event.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : PersianWeekDayNames and PersianMonthNames have became internal. Use PersianDateTimeFormatInfo class instead.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : When parsing a string representation of PersianDate e.g. 1382/08/23 time part was initialized from system time, but now initialized to 00:00 to be consistent with DateTime behavior.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : PersianDateConverter is changed access modifier to Internal. You should not use this class, and instead either cast instances of DateTime / PersianDate or use newly provided extension methods.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : Strings representing DateTime is now parsed using InvariantCulture when parsed to DateTime instance.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : Static Parse and TryParse method accepting DateTime instance is removed. Use constructor overload instead.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : &amp;quot;Readonly&amp;quot; property in FAContainerComboBox is made obsolete. Use IsReadonly property.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : Border color of control in Office2000 and WindowsXP was near white color. Now uses SystemColors.ControlDarkDark value.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : Created a new base class for FAMonthView, which will be base of other upcoming controls.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : CurrentMonthName property from FAMonthView is made obsolete. You can use the GetMonthName method on BaseCulturedControl class instead.    &lt;br /&gt;- &lt;font color=&quot;#ff8000&quot;&gt;&lt;strong&gt;Modified&lt;/strong&gt;&lt;/font&gt; : Arrows of the FAMonthView will gray-out if the control is in disabled state. Change of selected date is not available if the control is disabled.&lt;/p&gt;  &lt;p&gt;Notice that &quot;Modified&quot; entries might be breaking your existing code base, but you are encouraged to use this latest version as there were some rather important bugs fixed and some useful features is added.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Like always, get the files from my web sky-drive &lt;a href=&quot;http://cid-4962b6ceabc2cbd7.skydrive.live.com/browse.aspx/BlogFiles/Farsi%20Library&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
    </content>
  </entry>
  <entry>
    <title type="html">Farsi Library for the Web</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/farsi-library-for-web"/>
    <id>http://www.hightech.ir/SeeSharp/farsi-library-for-web</id>
    <updated>2009-10-19T07:53:39.797</updated>
    <published>2008-12-26T14:50:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="FarsiLibrary" />
    <category term="Calendars" />
    <content type="html" xml:lang="en">
      &lt;p&gt;There's been a lot of request for web and windows controls supporting multiple cultures and calendars, like the already existing WinForm Controls of Farsi Library. The existing ASP.NET Calendar control does not render correctly when used in other cultures and this is the case when you're using FA-IR culture. Although this problem is partially because FA-IR has a wrong calendar set for its default calendar (GregorianCalendar instead of PersianCalendar this has its own story too), there's no workaround. What I did was to create a new control to correctly render the calendar information in Gregorian Calendar, Persian Calendar and Hijri Calendar.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.hightech.ir/Images/BlogPics/FarsiLibraryForTheWeb.jpg&quot;&gt;&lt;img title=&quot;FADatePicker-Web&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;264&quot; alt=&quot;FADatePicker-Web&quot; src=&quot;http://www.hightech.ir/Images/BlogPics/FarsiLibraryForTheWeb.jpg&quot; width=&quot;345&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The control currently works exactly as ASP.NET calendar, meaning it supports all the use cases of standard ASP.NET calendar control like styling, using on update panels, etc. This control with a complementary DatePicker control will be added to the Farsi Library project as I'm planning for the next major release. The pre-beta sources will soon be available in case you are interested.&lt;/p&gt;
    </content>
  </entry>
  <entry>
    <title type="html">Farsi Library - FAQ</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/farsi-library-faq"/>
    <id>http://www.hightech.ir/SeeSharp/farsi-library-faq</id>
    <updated>2009-10-19T13:11:22.057</updated>
    <published>2008-10-28T11:46:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="FarsiLibrary" />
    <content type="html" xml:lang="en">
      &lt;p&gt;A lot of people keep asking me to provide a VB.NET Sample on how to use Farsi Library component. The library is written in C# after all and no sample code is provided to demonstrate VB.NET usage. This post is not a tutorial to Farsi Library per se. I'm answering some of the question regarding VB.NET usage, and some common questions about Farsi Library you've kept asking.&lt;/p&gt;

&lt;p&gt;Yet, there are still some people don't know how to create an explicit Main method in VB.NET, so if this post is a low-level for you professionals, just skip this post ;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q : I'm using VB.NET but there's no main method to set my thread's culture!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : Since everything supposed to be easier in VB.NET, you normally do not create an entry point for an application written in VB.NET, but only select a form which is the startup form of your application. To have more control on application initializations, you need to write the application entry method as well. Simply add a new Module (e.g. Named Program) and add a method to initialize and run the main form :&lt;br /&gt;&lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
Public Module Program
&amp;lt;STAThread()&amp;gt; _
Public Sub Main()
    Application.SetCompatibleTextRenderingDefault(True)
    Application.EnableVisualStyles()
    Application.Run(New MainForm())
End Sub
End Module
&lt;/pre&gt;

&lt;p&gt;To actually use this Main method, open the Project's properties by double-clicking on &quot;My Project&quot; in solution explorer and in the Application Tab, uncheck the check box that reads &quot;Enable Application Framework&quot; and set your startup object as &quot;Sub Main&quot;.&lt;/p&gt;&lt;p&gt;Now when running your application, the main form is created through the Main method in Program class. You can set a breakpoint to check if it is working. Easily add any additional initialization logic to the Main method. To set the running thread's Culture use this code :&lt;br /&gt;&lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
Imports System.Threading
Imports System.Globalization

Public Class Program
&amp;lt;STAThread()&amp;gt; _
Public Shared Sub Main()
    Thread.CurrentThread.CurrentUICulture = New CultureInfo(&quot;fa-ir&quot;)
    Thread.CurrentThread.CurrentCulture = New CultureInfo(&quot;fa-ir&quot;)

    Application.Run(New MainForm())
End Sub
End Class
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Q : I'm running a form with Farsi Library controls. All the dates are in Gregorian calendar.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : You need to set the running thread's culture information to &quot;fa-ir&quot; culture to see the Persian Calendar information. For Arabic calendar, use &quot;ar-sa&quot; culture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q : I've downloaded the source files but it won't compile. When compiling the sources VS.NET says the license key is missing.&lt;/strong&gt;

&lt;p&gt;A : Farsi Library is an open source project. There's no such thing as license key in this project. To be able to use the compiled dll in certain scenarios (Putting them in GAC, etc.) you need to specify a key which VS.NET uses to sign the built assemblies. If you get the latest version of the source code, the key file is included.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q : How can I use the Farsi Library on a Web Site or Web Project?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : I was going to provide an ASP.NET Server control in one of the first releases, but since my web project was canceled, there's no ASP.NET control available. However, you can use the FarsiLibrary.Utils project to convert dates on a web project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q : I have downloaded the binary files. What should I do with them? How can I use the controls?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : First, put the dll files somewhere near your solution / project (e.g. in a Lib folder). Then, you should add controls to VS.NET Toolbox. To do this, open the Toolbox window, right-click and select &quot;Choose Items...&quot; from the menu. On the next dialog, select &quot;Browse...&quot; button and select the &quot;FarsiLibrary.Win.dll&quot; file (or &quot;FarsiLibrary.WPF&quot; if you're working on a WPF project). All the controls will be added to your toolbox. You can simply drag-and-drop them on your form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q : I'm working on an application that uses a Database to store dates. On the UI I need to display dates in Persian Calendar. What should I do?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : Since you only need to &quot;display&quot; the dates in Persian Calendar, you can use DateTime data type on your entities as well as in your database designs. On the front-end, you can use FarsiLibrary controls which will bind to Business Entities, or DataSets, to display the DateTime value in Persian Calendar. You don't need to (and you're strongly advised not to!) use string data type (or other types) to support dates in Persian or other Calendars.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q : What type of look and feel does the control support?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A : Controls support System Theme (Windows XP, Vista, etc.) plus Office 2000, Office 2003, and partial Office 2007 themes. You can set each control's theme using Theme property, or use the global theme manager :&lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
FAThemeManager.Theme = ThemeTypes.Office2007
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Q : How do I change the strings used in controls? How can I localize the strings?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : Create a class and inherit from one of the available Localizer classes in FarsiLibrary.Resources namespace. Override GetLocalizedString method and provide a suitable representation for StringIDs you want. Later set the instance of your localizer on FALocalizeManager : &lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
Public Class ESLocalizer
Inherits ENLocalizer

Public Overrides Function GetLocalizedString(ByVal id As Resources.StringID) As String
    Select Case id
        Case StringID.Validation_NullText
            Return &quot;&amp;lt;Ningun fecha esta seleccionada&amp;gt;&quot;
        Case StringID.FAMonthView_None
            Return &quot;Nada&quot;
        Case StringID.FAMonthView_Today
            Return &quot;&#194;&#161;Hoy!&quot;
    End Select

    Return MyBase.GetLocalizedString(id)
End Function
End Class

FALocalizeManager.Instance.CustomLocalizer = New ESLocalizer()
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Q : I want to use the controls in another calendar. Can I use other cultures (e.g. &quot;es-ES&quot; culture) when using these controls?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : To globally change the culture set an instance of your culture on CustomCulture property of FALocalizeManager :&lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
FALocalizeManager.Instance.CustomCulture = New CultureInfo(&quot;es-ES&quot;)
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Q : How can I do validation to check if a selected date is correct? How do I restrict the selection to a specific date range?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : Use the SelectedDateTimeChanging event and set the e.Cancel to true. You can also set an error message on e.Message : &lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
Private Sub faDatePicker_SelectedDateTimeChanging(ByVal sender As System.Object, ByVal e As FarsiLibrary.Win.Events.SelectedDateTimeChangingEventArgs) Handles faDatePicker2.SelectedDateTimeChanging
Dim pd As PersianDate = e.NewValue

If pd.Day &lt;&gt; 20 And Not faDatePicker2.IsNull Then
   e.Message = &quot;Invalid date. Default Date is applied.&quot;
   e.NewValue = New DateTime(2010, 1, 20, 0, 0, 0)
End If
End Sub
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Q : How can I custom draw a certain day in calendar? How can I draw the holidays in red?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : You need to plug-in your drawing logic on DrawCurrentDay event. You have access to Day / Month / Year values as well as Graphics object. A Rectange representing date bounds is also available. Remember to set the IsHandled to true if you want to override the base class drawing logic : &lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
Private Sub faMonthView_DrawCurrentDay(ByVal sender As System.Object, ByVal e As FarsiLibrary.Win.Events.CustomDrawDayEventArgs) Handles faMonthView.DrawCurrentDay
If e.Date.DayOfWeek = DayOfWeek.Friday Then
    Dim br1 As New SolidBrush(Color.Wheat)
    Dim br2 As New LinearGradientBrush(e.Rectangle, Color.PaleVioletRed, Color.DarkRed, 45, True)
    Dim fnt As New Font(&quot;Tahoma&quot;, 8, FontStyle.Bold)
    Dim fmt As New StringFormat
    Dim dayNo As String = e.Day

    fmt.Alignment = StringAlignment.Center
    fmt.LineAlignment = StringAlignment.Center

    e.Graphics.FillRectangle(br2, e.Rectangle)
    e.Graphics.DrawString(dayNo, fnt, br1, e.Rectangle, fmt)

    br1.Dispose()
    br2.Dispose()
    fnt.Dispose()
    fmt.Dispose()

    e.Handled = True
End If
End Sub
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Q : How do I convert dates from / to PersianCalendar to / from Gregorian Calendar?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : You can convert instances of DateTime directly to PersianDate values, which represents their equivalance in PersianCalendar : &lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
Dim pd As PersianDate = CType(DateTime.Now, PersianDate)
lblCastTo.Text = pd.ToString(&quot;G&quot;)

Dim dt As DateTime = CType(PersianDate.Now, DateTime)
lblCastFrom.Text = dt.ToString(&quot;G&quot;)
&lt;/pre&gt;

&lt;p&gt;If you're using PersianCultureInfo (which uses standard .NET Framework Persian Calendar), you have access to all standard DateTime formattings as well. See MSDN page for &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/az4se3k1.aspx&quot; target=&quot;_blank&quot;&gt;standard&lt;/a&gt; and &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx&quot; target=&quot;_blank&quot;&gt;custom&lt;/a&gt; date formattings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q : I need to do calculations in Persian Calendar. I need to add / remove days to / from specific day in the Persian Calendar.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A : You can use the PersianCalendar class provided in .NET Framework to do so. There's an internal implementation of PersianCalendar in FarsiLibrary.Utils namespace which originally was historically developed before PersianCalendar appearing in .NET 2 : &lt;/p&gt;

&lt;pre class=&quot;brush:vb&quot;&gt;
Dim calendar As New PersianCalendar()
Dim pd = New PersianDate(calendar.AddYears(DateTime.Now, 10))
lblMessage.Text = pd.ToString()
lblToWritten.Text = pd.ToWritten()
&lt;/pre&gt;

&lt;p&gt;You can download VB.NET code related to this FAQ from &lt;a href=&quot;http://cid-4962b6ceabc2cbd7.skydrive.live.com/self.aspx/BlogFiles/Farsi%20Library/FarsiLibrary%7C_FAQ%7C_VBNET%7C_Demo.zip&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
    </content>
  </entry>
  <entry>
    <title type="html">Farsi Library 2.1 RC 2</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/farsi-library-21-rc-2"/>
    <id>http://www.hightech.ir/SeeSharp/farsi-library-21-rc-2</id>
    <updated>2009-10-19T13:29:59.267</updated>
    <published>2008-10-26T15:11:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="FarsiLibrary" />
    <content type="html" xml:lang="en">
      &lt;p&gt;Farsi Library RC 1 which released a few days ago, contains a new functionality : PersianCultueInfo. You can run your application setting an instance of this culture info on your application thread and you get the benefit of having a correct calendar for your application. Why is this important, you might say? Well, you'll have all the date related controls rendered to you in correct dates! Take a look :&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;center&quot;&gt;&lt;a href=&quot;http://www.hightech.ir/images/BlogPics/DXScheduler-With-PersianCulture.jpg&quot;&gt;&lt;img alt=&quot;Scheduler&quot; src=&quot;http://www.hightech.ir/images/BlogPics/DXScheduler-With-PersianCulture.jpg&quot; height=&quot;418&quot; width=&quot;629&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Now, there was a bug in RC 1 regarding mapped week days in PersianCalendar, that is fixed in RC 2. So, if you intend using PersianCultureInfo, you're strongly advised to use RC 2. For more info about Persian Calendar problem see &lt;a href=&quot;http://blog.hightech.ir/2008/10/persian-calendar-problem.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Like before you can grab the files &lt;a href=&quot;http://cid-4962b6ceabc2cbd7.skydrive.live.com/browse.aspx/BlogFiles/Farsi%20Library&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
    </content>
  </entry>
  <entry>
    <title type="html">Farsi Library RC 2.1</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/farsi-library-rc-21"/>
    <id>http://www.hightech.ir/SeeSharp/farsi-library-rc-21</id>
    <updated>2009-10-19T13:32:23.907</updated>
    <published>2008-10-15T11:21:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="NET" />
    <category term="FarsiLibrary" />
    <content type="html" xml:lang="en">
      &lt;p&gt;FarsiLibrary RC 2.1 is here. Some reported bugs are fixed in this release and some new features are added. Please report back any problem you may have. Please note that changes labeled as &quot;Modified&quot; *might* break your current application. It is advised how the modification will affect you (e.g. Parse and TryParse methods removed) and how you can fix it (e.g. use a constructor overload instead). If no bug is received, this version will be officially released as version 2.1 later. I'm still preparing a detailed FAQ / Tutorial on how to use this! Here's the change log : &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;Fixed&lt;/span&gt; : Rendering of controls in non-official themes or when a 3rd party windows skinning (e.g. WindowsBlinds) is installed.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;Fixed&lt;/span&gt; : Problem when setting SelectedDateTime property of FXDatePicker control to null value.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added&lt;/span&gt; : Methods SetTodayDate and SetEmptyDate added to FXDatePicker and FXMonthView which lets you emulate Today and Empty buttons respectively. &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added&lt;/span&gt; : PersianDateTimeFormatInfo that represents datetime formatting information for FA-IR culture.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added&lt;/span&gt; : PersianCultureInfo which is a FA-IR Culture with correct PersianCalendar and DateTimeFormatInfo.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added&lt;/span&gt; : More unit test to fully cover Utils project.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added&lt;/span&gt; : DateTimeExtensions to help convert between PersianDate and DateTime instances via extension methods.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added&lt;/span&gt; : XmlnsDefinition is added to WPF namespaces. You can reference the controls assembly with http://schemas.hightech.ir/wpf/2008/FarsiLibrary namespace.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added&lt;/span&gt; : PersianDateValueConverter which can be used in WPF applications to convert strings representing DateTime to their PersianDate equivalent.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added&lt;/span&gt; : WPF Demo to show how to use custom date converters.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified&lt;/span&gt; : Localization of WPF controls are using mechanism like WinForm controls (using StringIDs). Redundant resx files are removed from WPF project.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified&lt;/span&gt; : Merged WinForm and WPF controls into one solution.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified&lt;/span&gt; : ValueValidatingEventArgs now passes HasErrors property of the control when raising event.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified&lt;/span&gt; : PersianWeekDayNames and PersianMonthNames have became internal. Use PersianDateTimeFormatInfo class instead.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified&lt;/span&gt; : When parsing a string representation of PersianDate e.g. 1382/08/23 time part was initialized from system time, but now initialized to 00:00 to be consistent with DateTime behavior.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified&lt;/span&gt; : PersianDateConverter is changed access modifier to Internal. You should not use this class, and instead either cast instances of DateTime / PersianDate or use newly provided extension methods.  &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified&lt;/span&gt; : Static Parse and TryParse method accepting DateTime instance is removed. Use constructor overload instead. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strike&gt;You can download the release candidate from my Space Drive page &lt;a href=&quot;http://cid-4962b6ceabc2cbd7.skydrive.live.com/embedrowdetail.aspx/BlogFiles&quot; target=&quot;_blank&quot;&gt;Here&lt;/a&gt;.&lt;/strike&gt;&lt;/p&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;Update : Download Farsi Library 2.1 RC 2 from my Space Drive page &lt;/span&gt;&lt;a style=&quot;font-weight: bold; font-style: italic;&quot; href=&quot;http://cid-4962b6ceabc2cbd7.skydrive.live.com/browse.aspx/BlogFiles/Farsi%20Library&quot;&gt;here&lt;/a&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;. Check &lt;/span&gt;&lt;a style=&quot;font-weight: bold; font-style: italic;&quot; href=&quot;http://blog.hightech.ir/2008/10/farsi-library-21-rc-2.html&quot;&gt;here&lt;/a&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt; for  more information regarding this new release.&lt;/span&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6069495622049300789-6702561936779568218?l=heskandari.blogspot.com'/&gt;&lt;/div&gt;
    </content>
  </entry>
  <entry>
    <title type="html">Persian Calendar Problem</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/persian-calendar-problem"/>
    <id>http://www.hightech.ir/SeeSharp/persian-calendar-problem</id>
    <updated>2009-10-19T13:54:14.823</updated>
    <published>2008-10-13T10:00:00</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="FarsiLibrary" />
    <category term="General" />
    <category term="Calendars" />
    <content type="html" xml:lang="en">
      &lt;p&gt;If you've read my &lt;a href=&quot;http://blog.hightech.ir/2008/06/persiancalendar-and-net-framework.html&quot;&gt;older&lt;/a&gt; posts, you already know about the problem of FA-IR culture and the default calendar. When creating applications that run in different cultures and languages, Date specific controls like DatePickers, Scheduling controls, etc usually use current Culture's calendar to calculate dates, and to represent a DateTime instance to string representation. Also, control developers use DateTime.MinValue as a default (not set) value. But what happens when a culture's calendar does not accept DateTime.MinValue as a valid date? One example, of course, is our &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.globalization.persiancalendar.aspx&quot;&gt;PersianCalendar&lt;/a&gt; in which the least possible date is 22/03/622 (in Gregorian calendar) that maps to 1/1/1 in Persian calendar. &lt;br /&gt;&lt;br /&gt;

&lt;div class=&quot;center&quot;&gt;
&lt;a href=&quot;http://www.hightech.ir/images/BlogPics/FarsiLibrary_DateComparison.jpg&quot;&gt;&lt;img alt=&quot;Date Comparison&quot; src=&quot;http://www.hightech.ir/images/BlogPics/FarsiLibrary_DateComparison.jpg&quot; height=&quot;293&quot; width=&quot;624&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/p&gt;

&lt;p&gt;It gets worse when you storing data in the database! Suppose a user that uses Gregorian Calendar has logged-in and selected a date in the valid range for Gregorian Calendar, but invalid for Persian Calendar (the red arrows in the picture). What happens when the first user saves the data, and then the user logged in with Persian Calendar tries to load it? You'll have a nice exception on your hand! (This, of course is a hypothetical example. It *might* not be possible to save the date prior to 1753 in some RDBMS). You can't even call ToString() method on DateTime instance that falls in the invalid range! &lt;br /&gt;&lt;/p&gt;  

&lt;pre class=&quot;brush:c-sharp&quot;&gt;
[Fact]
public void UsingInvalidDateRangeThrows()
{
 using (new CultureSwitchContext(new PersianCultureInfo()))
 {
    DateTime dt = DateTime.MinValue;
    Assert.Throws&amp;lt;ArgumentOutOfRangeException&amp;gt;(() =&amp;gt; dt.ToString());
 }
}

[Fact]
public void CanConvertToStringWithInvariantCulture()
{
 using (new CultureSwitchContext(new PersianCultureInfo()))
 {
     DateTime dt = DateTime.MinValue;
     Assert.DoesNotThrow(() =&amp;gt; dt.ToString(CultureInfo.InvariantCulture));
 }
}
&lt;/pre&gt;

&lt;p&gt;You'll get an exception complaining :&lt;/p&gt;&lt;p&gt;&lt;em&gt;Specified time is not supported in this calendar. It should be between 03/21/0622 00:00:00 (Gregorian date) and 12/31/9999 23:59:59 (Gregorian date), inclusive.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;I think I understand why guys at Microsoft BCL decided not to set PersianCalendar as the default calendar of FA-IR culture : Because your application / component may break if you switch to FA-IR culture, but why not set it as an OptionalCalendar?&lt;/p&gt;&lt;p&gt;Lesson learned : Avoid calling DateTime.ToString recklessly, specially if you're developing a Custom Control or creating a multi-cultured application. Pay attension to Calendar.MinSupportedDateTime property.&lt;/p&gt;
    </content>
  </entry>
  <entry>
    <title type="html">Farsi Library - Version 2.0 now available</title>
    <link rel="alternate" type="text/html" href="http://www.hightech.ir/SeeSharp/farsi-library-version-20-now-available"/>
    <id>http://www.hightech.ir/SeeSharp/farsi-library-version-20-now-available</id>
    <updated>2009-09-27T08:33:01.187</updated>
    <published>2008-04-14T16:00:00.003</published>
    <author>
      <name>HEskandari</name>
    </author>
    <category term="WinForms" />
    <category term="FarsiLibrary" />
    <category term="C" />
    <content type="html" xml:lang="en">
      &lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://2.bp.blogspot.com/_Z5KTIfnfuNs/SAM_56lN6GI/AAAAAAAAACU/DdSClSDHBkc/s1600-h/FAMonthView.png&quot;&gt;&lt;img style=&quot;margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;&quot; src=&quot;http://2.bp.blogspot.com/_Z5KTIfnfuNs/SAM_56lN6GI/AAAAAAAAACU/DdSClSDHBkc/s320/FAMonthView.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5189061459871393890&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;Version 2.0 of FarsiLibrary is now available. The following changes are made in this release :&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified &lt;/span&gt;: Migrated to Visual Studio .NET 2008. Still using .NET Framework 2.0, so you just need the new IDE to compile. Might affect clients using old .NET Framework 2.0 (without the new SP Installed).&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified &lt;/span&gt;: IComparer and IComparer&lt;persiandate&gt; are converted to explicit implementation in PersianDate class.&lt;/persiandate&gt;&lt;br /&gt;&lt;persiandate&gt;&lt;br /&gt;&lt;/persiandate&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified &lt;/span&gt;: ICloneable interface implementation is converted to explicit implementation in PersianDate class.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified &lt;/span&gt;: Assign method of PersianDate to internal.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified &lt;/span&gt;: Changed the Day/Month/Year change eventhandler type to EventHandler&lt;datechangedeventargs&gt;. You can use the New/Old value properties to access the underlying values.&lt;br /&gt;&lt;br /&gt;&lt;/datechangedeventargs&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified &lt;/span&gt;: FALocalizeManager now is a singleton class. Use the Instance property instead of static methods.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Modified &lt;/span&gt;: FAMessageBoxManager.Delete method now returns boolean value based on whether the delete operation was successful or not.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added &lt;/span&gt;: Implementation of IsLeapMonth method in PersianCalendar.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added &lt;/span&gt;: Solution Items folder.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added &lt;/span&gt;: Partial Office 2007 Blue theme. Drawing of dropdown buttons of FADatePicker control need a better visualization.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added &lt;/span&gt;: PainterFactory to create painters based on the state of BaseStyledControl.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;Added &lt;/span&gt;: FAMessageBox now implementes IDisposable interface explicitly. Dispose method is made internal.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt;Fixed &lt;/span&gt;: When changing the culture, Year value didn't change, e.g. when in Farsi culture in year 1385 culture is set to english, the year remain 1385 (which was a valid year in English calendar).&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt;Fixed &lt;/span&gt;: When changing the DefaultCulture property, Day and Month properties did not return the culture-specific values.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt;Fixed&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 102, 0);&quot;&gt; &lt;/span&gt;: A bug when accessing Now property of PersianDate class.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Please report any bug you might encounter. You can download the source code from &lt;a href=&quot;http://blog.hightech.ir/BlogFiles/FarsiLibrary_2.0_Src.zip&quot;&gt;here&lt;/a&gt; and the binary (including test project executables) from &lt;a href=&quot;http://blog.hightech.ir/BlogFiles/FarsiLibrary_2.0_Release.zip&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;More information about this project can be found on my Code Project article at &lt;a href=&quot;http://www.codeproject.com/KB/selection/FarsiLibrary.aspx&quot;&gt;here&lt;/a&gt;.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6069495622049300789-5588888989458478956?l=heskandari.blogspot.com'/&gt;&lt;/div&gt;
    </content>
  </entry>
</feed>
