Ali's profileAli DaneshmandiPhotosBlogListsMore ![]() | Help |
|
|
May 07 Restaurant WPF applicationMy first WPF application. I did it as a university assignment.
And here is the Demo Video
October 22 Persian support for silverlight 2.0The first important issue that every developer who desire to create an application on Microsoft Silverlight which uses the right to left languages such as Persian sould deal with, is to find a way to present RTL texts correctly on Silverlight content. The first time that I wanted to create a Persian Silverlight content I was really disappointed because Microsoft Silverlight does not support RTL languages well. So I decided to find a way to get rid of this problem. Now after spending hours and days the first result came into view; "Persian Support For Silverlight 2.0". This project provides a method to solve the RTL problem of silverlight for Persian texts. I upload it as an open source project on CodePlex website and you can download it from here. I 'll be glad to hear your ideas or comments.
Have a good time. September 02 Timers in WPFRecently I was working on a WPF app and I wanted to use a timer to do something automaticaly in the background and then update something in the UI. At first I was faced with some problems. But after all I found how I should use Timer in WPF So I decided to post it here for the ones who might face with the same issue.
First of all, here is the code which uses a timer to change the background color of the window with random generated color:
public partial class TimerTesting : Window
{ public TimerTesting() { InitializeComponent(); System.Threading.TimerCallback tc = new System.Threading.TimerCallback(this.OnTimerCallback); System.Threading.Timer objTimer = new System.Threading.Timer(tc); objTimer.Change(0, 500); } private void OnTimerCallback(Object obj) { Random r = new Random();
this } } When we wanted to set the background of the window in the Callback method this exception fires. "The calling thread cannot access this object because a different thread owns it.". This problem is due to UI thread in WPF is different from the thread that owns our timer. In fact, the Dispatcher object manage the UI (in this case the window). Therefore updating the UI should handle with Dispatcher object that owns it. So we should change our code in the CallBack method to this way:
private { this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (System.Threading.ThreadStart)delegate() { Random r = new Random(); this.Background = new SolidColorBrush(Color.FromRgb((byte)(r.Next(0, 255)), (byte)(r.Next(0, 255)), (byte)(r.Next(0, 255)))); }); } In WPF the only thread that created the DispatcherObject may access that object. Therefore we should first find the Dispatcher object of the window then tell it to update the data on the window. Moreover, The BeginInvoke method of the DispatcherObject executes the delegate asynchronously on the thread that the Dispatcher is associated with which in our code is the DispatcherObject of the window. In the Case of Timer, we can use three kinds of Timers in WPF which two of them were available before WPF; As we dicussed above System.Threading.Timer and System.Timers.Timer. But the third one is made especially for WPF; System.Windows.Threading.DispatcherTimer. The difference between this timer with the two others is that it belongs to the same thread as WPF UI thread. By that I mean the DispatcherObject owns it. Better say, in the case of our example above the thread of the window and the timer are the same so we can Update the UI data without any problem.
public {
public TimerTesting()
{
InitializeComponent();
System.Windows.Threading.DispatcherTimer dTimer = new System.Windows.Threading.DispatcherTimer();
dTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dTimer.Interval = TimeSpan.FromMilliseconds(500);
dTimer.Start();
}
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
Random r = new Random();
this.Background = new SolidColorBrush(Color.FromRgb((byte)(r.Next(0, 255)), (byte)(r.Next(0, 255)), (byte)(r.Next(0, 255))));
}
} You can download the complete source code here. Creating a CLR Persian Date Converter function for SQL ServerOne of the most exciting new features of MS SQL Server 2005 is its ability to host the .NET Common Language Runtime (CLR). This feature was not, however, designed merely to provide an alternative to Transact SQL (TSQL). In any development project, it is important to use the right tool for the right job. If you want to create a stored procedure that performs standard operations on relational data, then without doubt TSQL is the platform to choose. Since TSQL is designed solely for the purpose of manipulating relational data, it is superb at that job. However, there are many tasks which fall outside of the realm of relational data. It is for these tasks that CLR code might be a wise choice. Such tasks might include writing a Date convertor function to support Persian Date inside the Microsoft SQL Server. This is due to the lack of supporting Persian collation therefore SQL Server does not support Persian Date Time. However it seems that it should have, it is not yet affordable. We hope that Microsoft support it in the SQL Server 2008. Anyway, Thanks the .Net Framework 2.0 and later versions which has the PersianCalendar class in the System.Globalization namespace which enable us to use Persian calendar in the .Net environment. Now with the availability of embedding CLR functions into SQL Server we can write functions to convert the Georgian date time into Persian date time. In this article I will show how easy is to create Persian date time convertor in C# and then embedded it into SQL Server and finally use it as a function inside SQL Server environment. Because of the readability of the code I upload this article in Code Project. This the link: http://www.codeproject.com/KB/database/PersianDateInSQLServer.aspx July 29 New to .Net TechnologiesSome days ago a friend of mine called me, and asked me for a list of the things that people who are interested and eager to come into the .Net community or the ones who desire to continue their ways in .Net community more professionally, should know about. So I decided to write this paper and place it in my blog for those people.
A lot of people argue about the Microsoft and its tendency towards software or in general computer sciences. Some argue that Microsoft is a selfish company which wants to bring people and other companies under its control or it grabs others ideas and develop them in its own way, while others believe, Microsoft is a very successful company that can walk into any computer area and field and compete with giants of that filed effectively and after a while becomes the first one on that particular field. I myself tend to be in the second group, even I partially agree to some extent with the first group. Anyway, I am here to talk about the things that a .Net developer should know or be aware of not the fact that Microsoft is good or bad.
Because of the variety of the new technologies which exist in the .Net community it is hard to learn all of them at once. So it’s better to make a choice to study and learn what sorts of technologies which are suitable for us. Moreover, we need to learn those which we are more interested in or we are more talented on them. Some of these technologies refer to web applications, some of them fall into desktop environment, some of them are shared among them and the others do not tend to participate in any of these three parts. Another thing that I want to mention is that these things are for the ones who want to become professional in .Net and they are not for the ones who want to be as ordinary people. However, it is not impossible for a person to become expert in all of them; it seems so hard and challenging. Some of them seem essential while others seem elective for each one interest. Therefore, I split them into two groups; first essential ones and then elective ones.
Essentials1. High knowledge of a Microsoft .Net LanguageNowadays a professional .Net developer should know at least one .Net Language to get in by himself / herself in the .Net community. So knowing a deep understanding of the C# / Visual basic .Net is mandatory. The C# and VB have different versions know and they are well mature at this point of time. In C# there are three versions now; C# 1.0, C# 2.0 and C# 3.0. I am not informed of VB a lot, but I know VB 9.0 is the lastest version. From the C# point of view, it starts its existence from Visual Studio 2003 with its first version. At those points of time, it was not pretty mature, even, it seemed awesome. With the announcement of Visual Studio 2005 and the related technologies which came along with, it grows well. A lot of features has been aded to the language such as Generics and so on so forth which empowered it enormously. We should also pay attention to the revolution which the ADO.NET brought with itself by Dataset concept. Now in the C# 3.0 which came with Visual Studio 2008 there are plenty of features which enable the developers to do whatever he/she wants. Features such as LINQ and so on so forth are so awesome that encourage and tempt any developer to come into the .Net community.
2. Work experience with Visual StudioWe should thank Microsoft for its excellent IDE, Visual Studio, which combines all .Net technologies into one place and enables us to develop them in just one pretty mature IDE. Visual studio has also different versions, VS 2000, 2003, 2005 and now 2008 are the IDEs which we are familiar with them now. Each of which were some things in their own era and some of them are now. As they progress in versions they brought new features and tools to make developers more comfortable.
3. Knowledge of Microsoft SQL ServerAs Visual Studio, MS SQL Server knowledge is essential for a .Net developer. SQL Server started its way by SQL Server 7.0. And then it became 2000, 2005 and now 2008. Working with data is inevitable in programming. Therefore having a great knowledge and experience is so important. Whats's more, Knowing other Databases such as Oracle would be a benefit for a .Net developer.
Electives· ASP.NetASP .Net is a Microsoft technology to develop web applications. It stands for Active Server Pages which has several versions. Version 1.0, 2.0, 3.0 and now 3.5 is available and ready to use. Nowadays ASP.Net AJAX is an indispensible part of ASP.NET which has revolutionized web applications. LINQ is also available in ASP.Net 3.5.
· Windows FormsWindows Form technology is the former technology which Microsoft announced to enable developers to write applications for windows platforms. It is a well mature technology which is being used for a long time. This technology is now usable and Microsoft supports it and they said they will support it later on, too.
· Web ServicesA “Web Service” is defined by the W3C as a software system designed to support interoperablemachine-to-machine interaction over a network. Web services are frequently just Web APIs that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested services. The W3CWeb service definition encompasses many different systems, but in common usage the term refers to clients and servers that communicate using XML messages that follow the SOAP standard. In such systems, there is often machine-readable description of the operations offered by the service written in the Web Services Description Language (WSDL). As you got it is not a technology which belongs to Microsoft, but it is hugely used by Microsoft in the .Net environment.
· XMLXML is an indispensible part of the .Net technology. Most the technologies which come from Microsoft use XML enormously. And most of them came into view because of XML. Not only every .Net developer should get in by himself/herself in XML but also other developers who work with other technologies from other companies should know it.
· WPFWindows Presentation Foundation (WPF) is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of both standalone and browser-hosted applications. WPF is a new and magnificent technology which came into view to change the minds of every developer and designer in terms of GUI. It is getting used to create rich windows applications with the power of DirectX graphics in a much simpler way. Even though for higher graphics demands for the applications such as games Microsoft still offers DirectX, it has good graphic abilities. Microsoft Expression Blend and Design are for creating WPF applications and also Silverlight applications. However we can use Visual Studio for creating WPF apps, we use Expression Blend to create our application UI much more effectively.
· SilverlightMicrosoft Silverlight is a programmable web browser plug-in that provides support for rich internet applications such as animation, vector graphics and audio-video playback. Silverlight competes with products such as Adobe Flash, Adobe Flex, Adobe Shockwave, and Java FX . Now in beta-testing, version 2.0 brings improved interactivity and support for .NET languages and development tools.
· WCFWindows Communication Foundation, or just WCF, is a programming framework used to build applications that inter-communicate. WCF is the part of the .NET Framework dedicated to communications. WCF is Microsoft’s unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments.
· WFWindows Workflow Foundation is a framework that enables users to create system or human workflows in their applications written for Windows Vista, Windows XP, and the Windows Server 2003 family. It consists of a namespace, an in-process workflow engine, and designers for Visual Studio 2005. Windows Workflow Foundation can be used to solve simple scenarios, such as showing UI controls based on user input, or complex scenarios encountered by large enterprises, such as order processing and inventory control. Windows Workflow Foundation comes with a programming model, a rehostable and customizable workflow engine, and tools for quickly building workflow-enabled applications on Windows.
· Compact FrameworkThe Microsoft .NET Compact Framework is a key part of realizing Microsoft's goal to provide customers with great experiences any time, any place, and on any device. The .NET Compact Framework's managed code and XML Web services enable the development of secure, downloadable applications on devices such as personal digital assistants (PDAs), mobile phones, and set-top boxes.
· Micro FrameworkThe Microsoft .NET Micro Framework combines the reliability and efficiency of managed code with the premier development tools of Microsoft Visual Studio to deliver exceptional productivity for developing embedded applications on small devices. The .NET Micro Framework brings a rich, managed-code environment to smaller, less expensive, and more resource-constrained devices. Requiring only a few hundred kilobytes of RAM and an inexpensive processor, the .NET Micro Framework was built from the ground up to let you build applications using familiar Visual Studio development tools. With .NET Micro Framework SDK, you can develop your embedded solutions in C# using a subset of the .NET libraries focused on embedded applications. Your development environment is Visual Studio, where you can take advantage of its powerful editing, object browsing, project management, and debugging capabilities. These capabilities are available when using the .NET Micro Framework SDK's extensible device emulation system or on real hardware.
· SharePoint ServerMicrosoft Office SharePoint Server 2007 is a new server program that is part of the 2007 Microsoft Office system. Your organization can use Office SharePoint Server 2007 to facilitate collaboration, provide content management features, implement business processes, and supply access to information that is essential to organizational goals and processes. You can quickly create SharePoint sites that support specific content publishing, content management, records management, or business intelligence needs. You can also conduct effective searches for people, documents, and data, participate in forms-driven business processes, and access and analyze large amounts of business data.
And so on so forth.The story of Microsoft .NET does not have an end because there are plenty of other Microsoft technologies which can fall into the .Net. Such as Microsoft Robotic studio, F# functional programming language, Microsoft Surface and so on. Personally I love Microsoft not only because of these sorts of technologies but also because of its tendency to move forward.
Finnaly I would be pleased to hear form active .Net community members about this paper and try to correct it if it has mistake or it should contains other things to be considered more complete and professional to help the developers and other people who wants to participate in the .Net community to broaden thier horizons about the .Net.
So if you are eager to move on you can start from http://msdn.microsoft.com/en-us/beginner/default.aspx.
Good luck.
Resources: MSDN,Wikipedia July 17 Persian Date Viewer Gadget for VistaThis is a Persian Date Viewer gadget that I created. First download the 'PersianDateViewer.gadget.zip' from here then extract it and copy the extracted folder to the "C:\Program Files\Windows Sidebar\Gadgets". After all, it will be available on your windows gadget list therefore you can add it on your Windows Sidebar.
Enjoy it. |
|
|