Like this Blog on FB

Monday, December 13, 2010

Change the Scroll Bar Color - Silverlight



Hello Folks,

Here I hit the Bloggers' world all over again. Yes... with a technical posting.
Here is a very brief description of the problem:

The color of the silverlight scroll bar was looking very ugly in one of my projects and it needs to be changed. Am so sure that the regular, default pale scroll bars suck most of the time. But, we lazy coders never seem to care to change it. Rather we tend to compromise. When it 'NEEDS' to be changed. Please go ahead and follow the post. Few simple steps and a few minutes of time, You are done.

Tools Needed: Microsoft Expression Blend.

Time taken: 5 Mins.

When you are all set start off with this

Step 1: Open a new project in Expression Blend and drag a scroll viewer control on to the Layout.


Step 2:

o Go to Objects and timeline,

o Right click on the Scroll Viewer

o Click on Edit Template and

o Select edit a copy


Step 3: Specify a name in the Dialog Box that appears.

Step 4: Once you do so you will find the scroll viewer being made by mending many bits and pieces viz. Scroll Content Presenter, Rectangle, Vertical Scroll Bar, Horizontal Scroll Bar etc.


Now, that we have already got the individual parts. Here starts the customization part.

Step 5: Select the individual element you want to customize or change in the scroll viewer. My target now is to change the color of the scroll bar. So I select the Horizontal Scroll bar. And repeat the Step #2.

Step 6: Specify a name in the Dialog Box that appears. Make sure that you give a meaningful name and remember it to use it at a later time. Otherwise you might end up in ruckus.

Step 7: You can now see that the Horizontal Scroll bar is made of few more isolated components such as Rectangles, Horizontal Thumbs etc. The Horizontal thumb is the actual scrolling part of the scroll bar which can be moved. So our aim is to change its default color. Repeat the Step #2 on the Horizontal Thumb. In the dialog box give any meaningful name.

Step 8: Now we arrive at a destination of the real work. The thumb is made of a group of nothing but just rectangles . In order to change the basic Look and Feel of the Scroll Bar, select the “Background gradient” rectangle and navigate to the Properties window.

You can see all the colors are set to white in the Properties panel. Now unleash the designer in you and sharpen the creativity as you proceed with the next step.

Step 9: Change the colors on the gradient bar to the colors you wish to or the colors you are demanded for. You can change the no of colors and order of the colors. I now stick to 4 colors and change them to violet and shades of violet.

P.S : Change the BackgroundMouseOver Rectangle colors in the same manner. If you don’t do so your Scroll Bar looks like some south Indian comedian’s Black oily face …in short UGLY

Step 10: Click on the Return to scope and Underlined Upper Arrow button in the Objects and Timeline window(see the Image). Click the same button till you reach the Layout root level where you see the Scroll Viewer


Step 11: Now its Climax time; Apply the Edited style to the scroll viewer. Identify the scroll viewer, right click on it, and Go to Edit Template, Click Apply resource (By doing this we apply the style which we have created).

Step 12: Select the Style with the name you have specified in Step #6.

Save the application and Run it. This is how the Scroll Viewer looks like in the Browser.


You can see the Ugly and Regular Pale scroll bar in 2 and 1 is the Colorful scroll bar which we have created. Now tell me which one really Looks “ROCKING”……….!!!!

-Happy Coding


Cheers,

Sriki



Monday, May 10, 2010

Getting the UNC Path of the Network Drives using DllImport, C# and .NET Framework

Folks,
Back again. Once again I was lazy for the past month and half and was dull at the bloggers end. I have been doing more productive work for the last couple of weeks and hence there were no posts from me. However, finally I am at writing a post. People who know me closely and have moved closely with me, please hold your hearts strong because this is a head-toe technical posting and it is related to C#. Yes, finally here I go with a techie posting YAY!. Since the post is more educational I chose to use more formal 'language and format' of writing.

Problem:

One of the requirements of the product that I was doing is like this: There will be a screen in a windows based application and it consists of a combo box. The combo box should display the network drives of the computer. For those who are less literate about network drives; Network Drives are those locations that are mapped to a drive or folder in another system which can be accessed over network. Usually it is often painful to manually navigate to the network location and access the files there. So windows allows us to create network drives on our machines such that we can access the desired network location with just one single click.

How to create a Network Drive?

The creation of network drives is a very simple process.
  • Open My Computer --> Select tools from the menu bar--> Select the Map Network Drive option.
  • This opens a window which has a combo box with the existing network drives and non networking drives.
  • Upon selecting a drive the text box below the drop down list will display the path that the network is mapped to.
  • Once you select the drive letter from the combo box , Enter the Network path in the text box and click Finish.
  • Now you should be able to view the network drives in the my computer screen.

Solution to the Problem:

If you have ever worked on .NET you would certainly know how vast is the base class library of .NET. We can do many things with it. Yet, we cannot do everything using just the .NET framework and the BCL. Windows OS( XP,VISTA,WINDOWS 7) uses a special assembly called 'mpr.dll". mpr.dll is a module containing functions that are used to handle communication between the Windows operating system and the installed network providers. This assembly basically takes care of the relation between Drive Name Versus the Network Path. So we use the same .dll to fetch us the information that we need. The assembly should be referred as an external assembly and values should be passed to it. Inorder to do this we use the DllImport attribute method to point to the mpr.dll. We must point the Drive letters to the external Dll this shoud be done with the help of MarshallAs attribute.

Have a look at the following code.

namespace Srikanth.Samples
{
public static class Pathing
{
[DllImport("mpr.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int WNetGetConnection(
[MarshalAs(UnmanagedType.LPTStr)] string localName,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder remoteName,
ref int length);
///
/// Given a path, returns the UNC path or the original. (No exceptions
/// are raised by this function directly). For example, "P:\2008-02-29"
/// might return: "\\networkserver\Shares\Photos\2008-02-09"
///

/// The path to convert to a UNC Path
/// A UNC path. If a network drive letter is specified, the
/// drive letter is converted to a UNC or network path. If the
/// originalPath cannot be converted, it is returned unchanged.

public static string GetUNCPath(string originalPath)
{
StringBuilder sb = new StringBuilder(512);
int size = sb.Capacity;

// look for the {LETTER}: combination ...
if (originalPath.Length > 2 && originalPath[1] == ':')
{
// don't use char.IsLetter here - as that can be misleading
// the only valid drive letters are a-z && A-Z.
char c = originalPath[0];

if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
{
int error = WNetGetConnection(originalPath.Substring(0, 2), sb, ref size);
if (error == 0)
{
DirectoryInfo dir = new DirectoryInfo(originalPath);
string path = Path.GetFullPath(originalPath).Substring(Path.GetPathRoot(originalPath).Length);
return Path.Combine(sb.ToString().TrimEnd(), path);
}
}
}
return originalPath;
}
}
}
As far as my requirement is considered I have a combo box which is currently used to display all the drives that are there in my computer. Irrespective of whether the drive is a network drive or a local drive the current combo box displays all the drives. My requirement is to only display the network drives that are available there in my system. How do I do this? Thanks to the .NET framework, the DriveInfo class of the framework allows you to search through all the drives that are available on the machine. All that I needed to do was just ,run a foreach loop which looks for the Drives which are of network type.

This is as simple as this:


DriveInfo[] allDrives = DriveInfo.GetDrives();

foreach (DriveInfo d in allDrives)
{
if (d.DriveType == DriveType.Network)
{
cmbbxDrive.Items.Add(d.ToString());
}
}

Doing this will allow me to fetch the only network drives into the combo box. Upon selecting one of the drives the Drive's Letter will be sent as a parameter(LPStr) to the MarshalAs method. The "Mpr.dll" will now do the respective task and returns us the string which is essentially the path of Network Drive and the Folder eg:"\\MyServer\MyFolder". As per the need one can split the path further and save into Database. Otherwise you can send the one who assigned you the task a message saying "MISSION ACCOMPLISHED"


Hope this is better than the love tips post!

Cheers,
Sriki

Friday, March 5, 2010

Friends: Rajesh Kumar Sinha.

Rajesh Kumar Sinha.
Banda Jitnaa simple... simple utna intro.The first person I have seen at HCU who has unexpectedly become a major importance in my life.
I still remember when did I first see him. He was with a Mustache ON and it was in GB hall. First person in the list on the admission day.
At that moment I never knew that I am probably gonna stay with him in a same hostel, same wing and mostly the same room. He was simple and sober right from the initial days and he still is. That is the best part of Sinha (Sinha ji as venu calls him). I call it destiny and destiny is the only thing which lets you meet people who are away million miles and once you meet them it is worth million lives of bonding. I, rite through the inner layers of my heart cherish the relation with Sinha for the forthcoming lives together. He is too sweet a dude to hang along with.
Sinha and me along with Venu and Noops have spent days and months together on the roads roaming HCU through its Length and Breadth. In the initial days we were in same wing and right from seeing each others faces at the Loo till Good Night wala pissing we used to see each other quite often. Later right from the second semester our bonding grew stronger.I have some words for him which I could not actually speak out because We've never come across such an occasion. But thanks to Blogger; I am very strongly inspired by Sinha. It was not something that he has preached me or taught me but an undercurrent process that had a strong impact on me. If I have transformed myself into a more matured kind of human being 'Yes' Sinha is a part of the change. The way he lives and experiences practicality is the best feature of him. Its rare that you predict what happens exactly to you in the next coming months/years as a result of what are you doing 'NOW'. Sinha has got that 'Khoobiyat'. He usually is a very calm and understanding friend/Son/person who often compromises to make people around him happy. This is one of the lessons I have learnt from him. He always stands for truth and one needs lot of guts to do so. Accept the FACT is the word..... may be you are wrong at times, may be you are supporting the wrong mob -ACCEPT it. Whatever it is: Life, Friend, Grade whatever it is..........
Ok enough of formal positive qualities, let me recollect some lingering memories with him. Sinha initially had a cycle and I had a scooty. I was sick driving beside him on the uphill road so.. I used to hold his right hand with my left hand and ride my scooty thus.. both of us reach hostels at same time at same momentum. I now, wish someone had really taken a pic of such a moment. It looks so Bollywood but that was one of the best moments I have experienced. The very group titled 'Family' has bagged lot of memories just because of his presence. The optimal rectangle seating arrangement( Rajesh and Venu in the front row followed by Me and Noopur for copying in exams) was his architecture. He is the one who saved our asses being burnt many times by the Faculty. Sinha learns all week and explains rest in few hours that we can actually go face the Goddamn minors/Majors and assignments/projects at HCU which are sure nightmares for students. He is yet another Dennis Ritchie - a complete leader of C who has understood and corrected my project in hours of time. Thanks for the B in Programming Methodology dude. I just find a drape of tear in my eyes whenever I remember the day when we dragged a Huge Dried tree for over a kilometer for the mid night campfire at the Open Dais.
There is a very big list of memories we shared together:
  • Chai Dukaan at F Hostel,
  • Mess card hamesha open Phir bhi dinner at GOPS,
  • Shaam ko Honeywell se jaldi aake Chemistry Dept ke paas waala Mirchi khaana,
  • Raat ke 2 baje tak gappe maarke tab sar phir ke Helipad tak gaadiyon pe ghoomnaa,
  • Poore Bheege Bheege barish main Football finals at Gachibowli Stadium,
  • Sukoon ke 3 baje raat maastaan bhai's fuming coffee,
  • Vasundhra (Yet another unfogettable buddy) ko platina chalaate video lenaa....(again at some 2 am),
  • Aadhi raat tak Ladies Hostel yaa Gops ke paas baith ke gaadi pe sonaa
  • Last minute rush for the Coke for Vasundhra at 12 mid night( After she accepted ki woh mere pair padhengi..).
  • Pyaas lage toh gup chup Bhoookh lage toh ganne kaa ras,
  • Holi ke din ka recharge card wala incident and and and...............
  • thousands of memories more. I am sure I can write a book compiling all these memories.

I can never forget the expression in his eyes when I gave him this:
I have some how used my brain(I am not sure whether I have one??) to be a little creative and present him it. It is a collage of lot of photographs of him which I made it into a poster and packed in 9 layers... which included a Pepe jeans cloth on the top most layer. I am glad that he still preserves it with lot of care in his home.
Frankly there is no conclusion for posts like this because relations like this are everlasting and never ending. But to do the formalities I have some words to say to you through this: "Bro, you are absolutely amazing. You have been a real inspiration and support for me. I thank god that I have got people like you and venu are in my life and saaley you pray that you have people like me and aarthi in your life. By the way Guys: I feel so sad to say that Sinha is HAPPILY MARRIED. Yes Happily in bold italics. He has got an amazing life partner :beautiful Aarti with a much beautiful heart. He has got Two Dynamic kind of brothers who will be getting married soon...hehhe.....".


"In the pursuit of my higher academics at Hyderabad Central University I have come across a something like a rock... When I had a keen look at it I found that was a Huge diamond. It is of about 5'7" tall, lean and handsome Bokaro Cut Jharkhand Diamond: Rajesh Kumar Sinha...... Full Respect and loads of love... Please give a Very big Shout and Three cheers to our ultimate,eternal friendship which is travelling towards infinity and beyond..................."


Cheers ,
Srikanth

Wednesday, March 3, 2010

Friends: Venu

Alright guys... Here goes a posting which is most supposed to be a testimonial on orkut. But this guy cannot be defined in 1024 characters( atleast by me). I am sure I can write 1024 pages about him, that is the intensity of intimacy I have with him.... Ok let me brief about the man I am talking about. Mr. Venu Madhav Putta
aka Putta(Read POTTA) an absolutely genius mathematician (and he certainly is a better playboy to a mathematician). Some one who can work hard but still tends to work smarter and find the shortest path to the solution(we used to copy more and study less during exams.... Team Work means more work is the say ). Standing top in a national level entrance exam is no joke, this chap has made it through for the HCU MCA and a topper can actually copy in exams -work smart- get a job in TCS.

Its almost 5 years since I met this handsome,uber cool,ultra clever, Extra talented, mega flirtatious, super dynamic, hot, young and highly energetic chap. Ever since then, we have been the best of the best friends till date. Our wavelengths match so perfectly that we can speak each others mind's actually. This may be because he is not my friend but is more than my own soul to me.
I get so nostalgic and pleasant whenever I recollect the initial days of our friendship. I had lot of respect towards him and his talent(and yeah I still have it.....) . He is a Math lover and I am arithmophobic. Yet, there was one thing we have common in both of us. We loved singing and were actually better singers. Way down in our second semester we attended the auditions for the Singer search in HCU for the Valentines Days special orchestra and both of us got selected. We had about 10-12 days to rehearse and make it on to the big stage. I never knew then that those few days are going to make a real strong bonding between both of us. Finally the day came down and we could deliver our best on the DST dais on FEB 14th of 2006. Sure that day was a special day because the ONLY day I have ever gotten(actually) an upper hand over him. Other than that day I am always deprived and bowled by his love, affection.care and talent.
Both of us had thousands and lakhs of memories together.Venu is someone who has the real zeal within him towards learning new things and constantly practicing them. I must say his dedication was incomparable when he decided to improve himself in spoken English. I myself have seen him transforming from a below normal level English speaking student into a teacher who can teach 8 hours a day in English to hundred non Telugu speakers. One must clap for his endurance in learning. I feel proud that from a stage of learning vocabulary from me he has grown up to the level of teaching vocab to me. Hats off Venu...... we have done lot of mischievous things together. Though this post is to express my experiences with Venu, I feel that I need not disclose all the secrets. LOL.
If someone considers Venu to be very silent and sober man ; (S)He is gone. My Goodness.. You will die rolling on the floor laughing to his timing in cracking jokes.We have danced through so many DJ nights and tried seeing the peaks of fun. If friendship is all about cracking jokes,dancing together, roaming here and there; then yes we are friends. But there is another best part of him which is certainly the key thing in continuing the BEST bonding. I am sure he hates to read this if he is reading the post but... he is very kind and helping friend for me. During the 3rd semester of my stay at HCU when I was down with a road accident and still my professors wanted me to attend the classes in the wheel chair, I had to choose a place to stay for 2 months. Instead of being there in my own room I have chosen to stay in Venu's room. During those two months he protected me like a baby all the time. I must mention Sashi's name here who is no less than Venu for me in certain terms. Right from getting me brushed and making me bathe to visiting GOPS in the late nights with peeled hand and a broken leg on my scooty we have experience endless fun. We sang so many concerts (కచేరీలు) together over the Nokia 1108 phone(Please contact Venu for further details). We shared so may hours together and each second of them is unforgettable. I am glad that he is a very responsible son and brother who could get his sweet little sister married grandly.

Wait a minute; I am sure that if you have read this post completely till now you must also have had lot of respect to him. But, he is just not what all I have said. He has got so much of talent in tackling girls.He never cares what people talk behind him or whatsoever. Both of us have an answer for people who don't like us." The Following picture explains what is the answer better.

WE DONT GIVE A FLYING F**K

He made me do what not for the sake of ____. In the name of friendship and in the name of Venu I have done so many sins and I sincerely confess for all of them and I demand God that major part of those sins belong to Venu and he should be punished in HELL for all of them. He is goddamn responsible for the chits he made through SMS and sent us and Sinha and I are Not. He made me wait hours together to pick him up at the main gate and Drop him back at his room. Whenever I got a call to pick up Mr.Venu I never hesitated to leave my girlfriends all alone in the middle of the road and take a U turn to pick him up. Still he is not satisfied... He still continues to take away my life by making me take so many risks...... ( No more further info can be provided as it is hazardous for my survival).


On the whole, I am so happy and thankful to god that I have got to meet a person like Venu in my life. Without Venu I am incomplete.... Our No More together group called FAMILY(Noops,Me,Rajesh, Venu) will be incomplete. I wish him ( ..... and am so sure) that he scales very very greater heights. I wish he stops flirting (.....hopefully...) and gets married to a nice girl,(.....so that some of the single young chaps like me are left with some girls in this world).... I pray to god that he troubles me less and he stops taking away my deos..... and makes less part of his sins. @Venu you are someone who is really handsome,uber cool,ultra clever, Extra talented, mega flirtatious, super dynamic, hot, young and highly energetic chap and I am happy and Proud that you are my friend. Love you so very much.

Keep Smiling:

-Taarzaan( AKA Sriki)




Wednesday, February 10, 2010

Valentines Day Pravachan By SRIKI Baba

Hiya Friendz,

I have questioned myself recently...
What am I blogging and Why am I blogging??? LOL...
I thought Blogging just another way to reflect my persona.
I noted that I have been doing lot of preaching,teaching stuff and Yes all this messages I deliver are more generalized.
Any group of people can visualize himself as a reader of the post.
On this note, I have decided that I should seriously post something which is Specialized.
Something which is specific to some group of people.

After all I am not a baba to preach elders.
I am a just another young chap who has lot of dreams and dreamgalz who arrive often in those dreams......
Besides, you are not supposed to deliver speeches and make suggestions in those fields in which you lack experience.
Finally, I have decided to post a blog entry in that area I am well versed.

FLIRTING.........

I am not going to say how flirting can be done or something that related to...... Because I preserve that to be a topic of my research(Ph.D). Though I deny it often.. I have lot of friends who are GIRLS( This doesnt mean that I have Girl Friends in the Indian Sense).... and I used to hang out at Ladies Hostel in HCU I was always "flocked by girls around me" ( Bold, Underlined, Italics) as said by one of friends(I am not going to reveal HER name until her permission) which made me understand the un-understandable entity to a little extent. So, I guess that will be of a little help in delivering this post.

Unfortunately, without any reason for the hells sake I had a nickname called LG(Love Guru) and I have never done any justice to the nickname/title. So, I am trying my level best to suggest you some tips for a Happy Valentines Day.
  • Look your best. Invest in some new clothes, or some swanky new gadget. Look uber cool and have the right attitude.

  • Girls don't come calling. Well that is a myth, these days, sometimes, they do. But we do not want to take chances right? So let them know that you are available. How will you do that? A single status on the social networking sites help. Easier still, let it slip to a couple of girls in your team, under the oath of secrecy of course, that you do not have a partner, and trust me, it will get you the desired result if she knows about some girl who may like being with you!

  • If there is someone you have always had a crush on, this is the right time to connect with them. Call them up, leave a message, and if you get lucky, there is nothing to beat it. A Valentine's Day spent with someone you can't connect with is even worse than one spent alone.

  • Send out sweet 'will you be my valentine' message to some random mobile numbers. Someone may respond, if you have a wrong number you can always excuse yourself, but if by any chance your message is delivered to someone equally lonely, why not push your luck a wee bit. Some such 'wrong number' calls have the history of ending up in marriages!

  • Hit at your friends- friends. Well, we don't want to make it sound shady. But consider this – your best buddy may have a girl friend and she would have a friend who is not committed. Try hinting that you would like to accompany her – plan a double date – after all she is single isn't she?

  • Social networking sites have opened up new vistas. Explore, spend time on it. Look up ex-flames and crushes on these sites. Who knows when you could turn lucky?

  • If you are the type who loves dogs, find one to take out for a walk. The cuter the dog the better, girls have a weakness for men who does this. If you don't have a dog and are sure where to find the girl, trust me, it is not bad to borrow a friend's dog for this purpose. Just make sure that the dog does not bite you or the girl!

  • Stalk. It is not a crime, everything is fair in love and war remember? At the cafeterias, cafes, shopping malls. If the universal thumb rule for love is correct, there should be someone some where made just for you. And you can't just ignore the fact that she may be at these places. And once you have shortlisted some, make sure you speak in you phone, loud enough for them to hear, 'Dad, I m not interested in an arranged marriage, I ll get married to someone I like,' and give her a sheepish grin.

  • If none of these work, no hard feelings, love will happen to you in due course. Till then, you can just have a ball and indeed there is nothing stopping you from throwing a 'single's' party at home. And hope someone may turn up, who is just right for you!

So keep hoping, Keep Loving, Keep Flirting.......

After all who said that Valentines day is just for lovers....... It is a day equal for the Flirters too.
Happy Valentine's Day Guys...............( Yes...........I mean it.......JUST GUYS).

Cheers,
SRIKI aka L G



Wednesday, February 3, 2010

Roar with me.....save the Tigers!


At times it is quite devastating to hear that Our national animal is being hunted very brutally. The hunting is going beyond the limits and now the number of tigers that are left has gone far far beyond the danger mark. As per the latest statistics its says that there are just 1411 tigers left.


JUST 1411 - Quite a devastating number. Now the alarms are ringing high on the roads, its THE time to take an oath and take a step forward. I dont expect to see a revolution coming up by spending a few minutes of my time by keying down some words and eating some bandwidth. But, I consider myself to be successful even if a single reader who reads this post thinks for a while about the cause.



We are all just normal human beings who have lot of complaints with the life and people around us. We are busy often to care about things related to public interest like saving the tigers, global warming etc. But, we can excuse ourself by atleast joining campaigns like this to save the Planet. So guys please join the cause at the following location.

Roar along with us to make some difference.
Your roar can make our lifes better and the lifes of the tigers.

Save Our Tigers | Join the Roar
http://saveourtigers.com/JoinTheRoar.php

Lets take an oath to stop this here itself.
Lets not procrastinate it anymore.
Lets Protest against Killing Tigers.
Lets move a step ahead and quit using leather products made of wild animals.

Lets Live and Let live.............

Jeeyo aur jeenedo.......... ye khushi kaa hain raaz
Achchi aadat hi hain....................apnaa sartaaz.....



Cheers,
Sriki

Friday, January 8, 2010

Be ashamed of being Human Beings.

While thumbing through the facebook early this morning. I ve found one of my friends publishing this article.

Shame on those slumfucking bastards....SO ruthless and the Assholes are Ministers representing states. The most shittiest part is that there is a health minister involved in this...........

I want you to take a look at: Policeman attacked on road, ministers stare from cars, don't help


Feeling so bad to start a day with a news like this.


-Sriki