Thursday, June 30, 2011

C# Shortcuts (Alias ​​long namespaces and types)


The names of the identifiers of C # can be very long. For example if you are automating Microsoft Office in C #, you may want to do something as simple as MS Word to open and edit a document. You can use the "use" to create an alias for a class or namespace.


using ShortWord = Microsoft.Office.Interop.Word;
Now in code simply use ShortWord where ever you want...
ShortWord.Application = new ShortWord.Application() { Visible = True; }


C# Shortcuts (Using Statement)


Often, you will need to allocate a system resource or network resources, etc. Each time you need such a resource, there are three crucial steps to go through:

You will have the resource you use, and then get rid of it. If you forget to properly dispose of it, you create a memory or resource leaks. This is best illustrated through the following models


// Step-A. Allocation of desired object here
Font myFont = new Font("Arial", 12.0f);
try
{
     // Step-B. use the resource (myFont) here
}
finally
{
     // Step-C. Dispose your object here
     if (myFont != null)
        ((IDisposable)myFont).Dispose();
}
Using allows us to use to compress this to:
//Allocate the desired resource here
using (Font myFont = new Font("Arial", 12.0f))
{
    // Use the resource here
}
// The best part is that Disposal is automatic.


C# Shortcuts (Object Initializers)


When you create a new object, it is often necessary to assign one or more of its properties. The introduction of C # 3.0 you can now use object initializers, and to improve the readability of this, and reduce your code


Employee emp = new Employee();
emp.Name = "Mr Smith";
emp.Designation = "Driver";

Now make it short like this...
Employee emp = new Employee {emp.Name = "Mr Smith", emp.Designation = "Driver"};

C# Shortcuts (?? Null Coalesce Operator)

How often to check for null values ​​in the code?
Then the null-coalesce operator (??) is convenient. To see how this works, consider the following sample code.


object c = null;
object a = new object();
object b;

if (c != null)
    b = c;
else
   b = a;
Now using the "?" conditional statement you may write it as...
object c = null;
object a = new object();
object b = (c != null) ? c : a;
Now make it even shorter using ?? null-coalesce operator...
object c = null;
object a = new object();
object b = c ?? a;

C# Shortcuts (? Conditional Operator)


"?" operator is convenient. It allows you to pack a common "if then else" statement model in a single activity

Normally we use the following.


int x = 70;
int y = 95;
int min;

if (x < y)
  min = x;
else
  min = y;
But this can be written as...
int x = 70;
int y = 95;
int min = (x > y) ? x : y;

Tuesday, June 28, 2011

CSS Positioning - Elements Center Alignment


CSS is a mighty beast, and an integral part of any self-respecting web site. After all, this power comes a lot of different tricks you can use to accomplish the mission. Some of the tricks associated with the placement of content, and today we are going to do with it. This tutorial we are going to reveal some of the best ways to center the content when the content may be.

There are many ways the center of your content using CSS. Some are a little further forward than the other channel, but fortunately they are all relatively simple to implement. At the end of this tutorial, you should be able to do something like this:

I'm focused!

Center Horizontally

One of the easiest ways you can use elements of the center is the text-align: center on the package contents. For example:





I am Centered...




As you can see we use the property text-align both the content and packaging. It is because we center the text on the parent div that will be inherent inner div. So we must adapt our text inside div to the left. It is easy to implement, but not perfect.

We can indeed use the margins to the horizontal center of things as well. But when you use the margins, we generally have a content container that has a defined size. Sometimes you even have to give your wrapper contained an exact size, as well. For the first example, we started with the worst:





Again Centered...




As you can see that we have to give us both the packaging and the width of our container. Because we all know the numbers, we can do some 'math to reach our goal. We are half the width of the pack, which is 200 pixels, subtract half the width of the content. This gives us a margin of 150 pixels, which is the central fact in full. Although this is strictly forward and ensures that the content is at the center no matter what the width of our wrapper, it is an easier way.

This method consists in the margins of automobiles, which means that the CSS margins are calculated for us. In this case, we still have to give our content contains a wide range of ... but our package. This means that our budget can be any size you want. In addition, we can shorten the margin up / down left / right as well.





Atlast I Am focused...




This is usually the preferred method to center the content, but there is a problem. If you are looking for a good match, you must go to the text with the alignment method, such as automatic margins are not supported by all browsers. All modern browsers support auto margins, but not only in older browsers.

If you feel adventurous, try our latest example of the horizontal center. It is "relatively" the positioning of the contents of our container, and then move a little. This is what it would look like:







I'm focused!





Here we take the content and the relative position of it. This allows us to use the property left to move the content around us, which we used for the left: 50%. This will move the content, but not centralized, as the top left hand pointing to the center of the contents of the container, moves to the right. To satisfy this, as the first example, the margin is calculated half-width of our content, but this time we are reducing the current drive. The end result is a central content.

So those are the main ways to get in half horizontally and CSS. There are other tricks you can do things, but these methods are the most common, and in the case of the first two, the most dynamic. However, there is a trick to get things centered vertically.

Center Vertically

This is where the trick There are two ways to focus your content vertically on the page. But before you dig I want to emphasize that both methods require your content for a specified height. There are several ways to focus on content without having to adjust the height, but they showed a lack of compatibility between browsers. These two routes are your best paris.

The first way is exactly the same concept as our last example horizontally, except suitable for the vertical position. It looks like this:







I'm focused!





As you can see that the same basic concept. You respect the position of the content in the middle, then offset by half its height. It works in virtually any browser, you will meet, and is simple to implement. A good solution, but that's another way of doing things.

This solution is a bit strange at first, but it is the best way to center the content vertically. That said, it is a sensitive issue. Using a floating div to force the contents in the center of the page, and we all know that things float can be a pain at times. Fortunately, implementation is very simple:










The Centered!





So now we have this new arc, which can be called at the end float guide our container contents, a vertical center of the page. As long be remembered as the "clear" the entire contents of the container works as expected. To make things better, this method is said to be a very wise browser compatible, which means that it works with IE 5

While there are all sorts of crazy ways to center the content vertically, if you just want some centered text. Of course, you can use one of the solutions above, but this seems a little bit exaggerated. Well, it was our secret third option comes into play.







I'm focused!





This is one of the center line of the text, and I want to stress one. I'm sure you've noticed that the key to this method is the line height, which makes every line of text a certain height. This means that if the text is wrapped, the following line is 50 pixels high. This makes it a good solution if you need a quick solution for a line of text, but something else later.

So this is a set of techniques are the best solutions for centering content, then x and y planes They are simple to use, and get the job done. This concludes this tutorial, but just remember, when you need help coding have to do is connect the Code.

Being A Developer of Windows Mobile 7


I have a sad news :(  I have never built a Windows Mobile 7 applications.
As Guy Blend and WPF, which bubbled over in Silverlight, it may shock you, but time and effort (not enough of the former and too much of it) kept me do it Hello everyone. Of course, it does not allow Verizon Stinkin WP7 has not yet, but we hope that this issue will arrange soon.

Since I promised to write an annex to the mix in the action focuses on the mixture WP7, I think it's time we jumped on the bandwagon and made some WP7 development.

Where I am from

Since I have Visual Studio and Expression Blend installed everything I need to start developing was to download and install the developer tools Windows Phone. This includes the emulator and necessary WP7 types of projects. If you do not Blend or Visual Studio on your machine, free tools are a part of this installation.

Register App Hub

Since I intend to create and publish real applications I went ahead and created an account AppHub. There are some things you should know before you start. First, it costs $ 99 in advance, so be prepared to pay when creating your account. Second, you need a Live ID. Third, you can not create an account without a website URL. While this may seem trivial, it threw me because I did not create this site, I intend to use my phone still Apps. I went ahead and use this site with the hope that I can change it later.

The next thing I did not expect the requirement of a tag as a player. I'm not a gamer, I do not own an Xbox, and I'm not sure what player is a tag, so I obviously did not deliver. I was stuck on the screen gamer tag you want for a while until I found one I wanted, which was not taken (theblendguy).

The last thing that threw me for a circuit that was to fill in forms, all copies is strongly oriented to XBox Live. Once past the home screen, everything I've read the account was in XBox Hub of the application: there was no mention of Windows Mobile 7. I canceled to make sure I had made the right decision, but decided to go to my guns, especially when I saw the price was right. In fact, when all was said and done, I had the appropriate account.

I received an email confirmation, and graduated from the account. If I understand correctly, the next step is to contact me and GeoTrust to verify I am who I say I am. I like the fact that Microsoft is putting so much effort to examine the accounts and applications: in the long term should mean a stable quality of the applications, which is the beginning, if you want to succeed.

And here is the next step...

The next step is the development of applications. I have a couple in mind already. I'm going to write my experiences as I go forward, so keep watching this space.

The next day I created my account, I received an email from GeoTrust take me to another site where I had to verify my identity. From the start, be prepared for some questions seem intrusive. I had to give them my social security number and possibly my license and some less info such as date of birth and address. Also, if you have been at your current address for less than two years, you must provide the previous address.

This information is the first step. When you place this time, another page comes with a set of questions specific financial, which, theoretically, you should be able to respond. I received questions about my mortgage and car payment, including a couple of trick questions. The answers are multiple choice, so you do not give them special, and it does not matter, because it seems they know it all already anyway.

Of course this is all done in HTTPS, so I'm not concerned about the safety of me when I use a credit card online. I was quite surprised that although the BI is in place to develop a trick question that I mentioned. (And no, I'm not going to be more specific). Overall, the process was tedious, and I passed the test at this stage I'm just waiting for my developer ID AppHub. I will keep you all posted.

And wait for the message in your inbox.

Now that you're an official you can start to develop, and applications.