Tuesday, December 2, 2008

Little tidbits about Silverlight 2.0

If you are developing a custom control in SL 2.0 and want to make your control through XAML Resource dictionary, remember to do two things:
1. The resource dictionary must be named "generic.xaml".
2. It should be placed in "Themes" directory.
You do that .... you are golden .....
Cheers !!!

Friday, November 21, 2008

Silverlight 2.0 and Textbox control that understands TAB key

So we are writing a small application in Silverlight 2.0 and wanted a textbox where if the user presses the TAB key, the cursor stays in the same box with a "Tab" ["\t"] inserted at the place of the cursor and the curs. Unfortunately like any other web platform, here also "Tab" has become more like a navigation mechanism which you use to navigate from one control to another.

So here is what we did. First we wrote our custom component which extends a regular TextBox. By default we set it's "AcceptsReturn" field true. Then we wrote a simple function named "HandleTab()" which will insert a Tab ("\t") character at the place of the cursor.

After you are done there, now what is remaining is to capture the "Tab" key press event. This needs to be on the container and not on the control itself. Unfortunately onKeyUp event does not capture the Tab key so we need to do it in onKeyDown event handler. Obviously we would want to capture this event for just our text box & that too on the "TAB" key, we will do the following:
============================================
void tb_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key.Equals(Key.Tab))
{
if (e.OriginalSource.GetType().Equals(typeof(CodeTextBox)))
{
(e.OriginalSource as CodeTextBox).HandleTab();
e.Handled = true;//prevent further propagation
}
}
}
=======================================================
and here is the code for HandleTab() function
----------------------------------------------
public class CodeTextBox : TextBox
{

public CodeTextBox()
{
this.AcceptsReturn = true;
}

public void HandleTab()
{
string tbText = this.Text;
int cursorPosition = this.SelectionStart;
int contentLength = tbText.Length; if (cursorPosition >= contentLength)
{
this.Text = tbText + "\t";
}
else
{
string leftSideContent = tbText.Substring(0, cursorPosition);
string rightSideContent = tbText.Substring(cursorPosition);
this.Text = leftSideContent + "\t" + rightSideContent;
}
this.SelectionStart = cursorPosition + 1;
}


}
============================================
This is pretty basic stuff but I think it can get the job done. Shift+Tab is yet to be implemented.

Also I don't know why but when you [Tab] does not insert 8 characters like you would normally expect. However when you copy the tabbed code from this textbox to your notepad or any other windows application, you see text as you would normally see. Any ideas?

Any comments??

Enjoy!!!

Sunday, October 26, 2008

In the office now

Here is another update from myself. Now we are moved into a new office. It's not fancy but sufficient for us. We are now a team of 6 people (including myself). As a startup it is always challenging to channel your energy and I must confess I got swayed a couple of times. You see it is very easy to succumb to common conventions and beliefs. In software world & especially in India, it is outsourcing. If you have a company in India and are working in the field of software development, chances are you are doing some kind of offshore software development work (in fact it is expected out of you). Sometimes it becomes hard to convince and explain people that you are doing product development. In past two-three months we thought of delving into outsourcing and starting a brand new business all together. But now I think everything is back on track and now we are moving in full swing.


Anyways team is really picking up and so far I am quite happy as to how things are shaping up. One good thing about hiring fresh engineers is that for them everything is new and are willing to learn without any prejuidice which I really like. Although you end up spending too much time with them explaining things but that's OK. I can only hope it will pay off in time to come.


We are also in the process of starting two new products. More about it will come in the coming days so keep on checking this space. Right now we are redesigning our Omega website. What we feel at this time is that the site is not easy to use and we want to address this issue. Furthermore I believe we are now ready to release Omega.MSSQL (it has been running in Beta for quite some time now) so the website relaunch will also include that as well.


That's it for now .... as they say in Chinese ... it's time to say 再见 or zài jiàn ... which means good bye ...
Cheers !!!

Thursday, September 11, 2008

Safari Books Online

So I wanted to subscribe for Safari Books Online. If you don't know what Safari Books is, I would recommend that you visit http://www.safaribooksonline.com/. Anyways they offer two products for individual subscription: Safari Library (expensive & good one) and Safari Bookshelf (cheap & not so good one). When I went to sign up on their site, to my surprise I did not get an option to subscribe for Safari Library. In response to a ticket submitted to their customer support, I got a response "India is not one of the country they offer Safari Library". This makes me wonder the country which produces most of the IT talent is not in the list of countries that can have access to Safari Library subscription.

Huh!!! Go Figure!!!

P.S. There is a catch here and people in India can still subscribe to safari library if they want to. All they have to do is log on to a VPN network in the US (like I did) and get a US IP address and you will see an option to choose Safari Library.

Tuesday, September 9, 2008

Omega.MSSQL

Omega.MSSQL (http://omega.cerebrata.com) is the first product of our company. In a nutshell Omega.MSSQL provides a browser based access to your SQL Servers. So now using just Internet Explorer (it looks real bad in other browsers!!!), you have access to your SQL servers. I can go on and on about this product but here are the highlights of the product:
  • Supports SQL Server 2008, 2005 & 2000 out of the box.
  • Allows you to create/alter/drop most of the common database objects (Tables, Views, etc.). It has a designer features for objects like User Defined Table Types which is not available in any tool at this time.
  • Allows you to search for meta data - This is one of the coolest features available in this product. Have you ever wondered where all a column by certain name is used in your database (try finding it in Enterprise Manager or You end up writing your own scripts)? Well Omega.MSSQL makes it easy for you. You just type in what you are looking for and where you want to search (tables, views, stored procedure etc.) and Omega.MSSQL will give you a list of all the objects grouped by object type.
  • Allows you to document the database.
  • Allows you to build and execute queries. This is a feature where we need to do some improvements but we are eagerly waiting for Silverlight 2.0 and then we will probably porting the software from there.

Anyways check it out. URL is http://omega.cerebrata.com. This is currently in its final Beta Stages. We hope to release it in production in next few months.

Monday, September 8, 2008

Back in India

Hello readers. My name is Gaurav Mantri & I recently moved back to India after spending 10 years in the USA. I intend to use this medium to share my experience. I actually wanted to start writing this when I got back (middle of July) but I finally got a chance to settle down. So there will be old events (when I got back) I would be writing about. Ihave also started a software development company [Cerebrata Software, www.cerebrata.com] here in India and will share my experience in setting up a company from scratch & growing pains. Other than that, there will be many more things ranging from software to movies to politics to religion to anything possible under the sun. So keep watching this space.

Cheers!!!