Bill Morefield My thoughts, discoveries, and occasional rambiings.

May 19, 2012

Review of RoboForm on Windows.AppStorm

Filed under: article — Tags: , , — Bill Morefield @ 8:47 am

My review of RoboForm is up at http://windows.appstorm.net/how-to/passwords-the-right-way-with-roboform/.  This is a program I recommend with no reservations to manage the passwords to the web sites you log into.  Why is a password manager important?

You may not care if someone gets your password to a simple web app you tried one time two years ago, but if you use that same password at your bank, for PayPal, or for Facebook it might be a disaster. It’s not just small web sites thrown together quickly that have their password stolen, but large companies like Valve and Sony.

The solution? A password manager will remember and store the login information for all your websites. It allows you to quickly create random passwords for each site and then recall those credentials when you next need to log in. You use a single strong password to protect all of these passwords. Here we’ll look at the popular password manager RoboForm.

May 8, 2012

A Look at Send to Kindle for PC

Filed under: article — Tags: , — Bill Morefield @ 8:42 pm

My newest article up on Windows Appstorm.

http://windows.appstorm.net/how-to/easier-reading-with-send-to-kindle-for-pc/

April 19, 2012

How To Article on Easily Reinstalling Windows Published

Filed under: article — Tags: , , , — Bill Morefield @ 10:02 pm

My article on easing the reinstall of Windows 7 has been published on Windows.Appstorm.

April 12, 2012

How To on Ninite Published

Filed under: article,web — Tags: , , — Bill Morefield @ 7:27 am

My second article for Windows AppStorm is out today.  This one is a how to on using Ninite to quickly install many popular Windows applications.  You can read the details at http://windows.appstorm.net/how-to/utilities/ninite-the-fast-way-to-install-windows-programs/

April 9, 2012

Skinning a Windows Form Application

Filed under: c#,development,windowsforms — Tags: , , , — Bill Morefield @ 9:30 am

The normal application window looks like a simple, basic rectangle.  For most uses it works quite well though providing a nice and familiar wrapper for a program.  It’s a bit boring though.  Sometimes though you create a program that doesn’t quite fit the normal square window.  Maybe you’re creating a custom display.  Whatever the reason, you are not limited to the standard window look.

I recently started updating and cleaning up a few applications I’ve written for my own use.  One of them works as a target to drag files onto and really cried out for something other than a square window.  I decided to create a nicer interface and in this post I’m going to show how to create a Windows form application with a custom look.

Step One: Tear Down the Default Form

When you skin a window, some of the things that Windows normally does for you now have to be done manually. Before we apply our custom look, we’ll start by getting rid of things we don’t want and then recreating those lost elements.  Let’s start with the form that you get when create a new Windows Form application in Visual Studio 2010. It looks like this when you run the application.

clip_image001

We want to get rid of the menu bar and those buttons in the top right window.  We can easily do this by changing the window type. In the form’s properties Change the FormBorderStyle attribute from the default Sizable to None.

clip_image002

If you run the program at this point you will get a plain grey window.  If you try to click on the window and move it, you will find it ignores your request. If you try to resize the window, that also will not work. You will also find nothing to click and exit the application.  By changing the border style to none, we also lost the built in support to move the window, close the application, and resize the window.

Step Two: Recreate Lost Functionality

We therefore need to add any of these features that we want the user to have. At the least we should give the user a way to close our program. For simplicity, I’m going to add a handler so that if someone right clicks on the window, the program exits.  In a real program, right clicking might bring up a context menu with an exit option.  The method it’s invoked doesn’t matter as this code will close your application.

        private void SkinnedWindow_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                Application.Exit();
            }
        }

If you now run the program, you will again see a simple gray square.  If you right click on the window, the application will nicely exit.

In most cases we will still want to allow the user to move our application.  I found a good way to allow moving a skinned windows is to start the move when the user presses the left mouse button while on the window. They can then move the window while they hold the left button down. When the user releases the left mouse button, the window will remain at that location.

To implement this, the application needs to handle the MouseDown, MouseMove, and MouseUp events for the form. In addition, we’ll need to keep track of when we’re moving or dragging the window and the form’s location when we start moving it. So we’ll add two variables to the form class store this information.

        private Point _offsetPoint;
        private bool _dragging;

When the user clicks the left mouse button on the window we simply want to note that we’re entering a state where the user is moving the window and store the initial location where the user clicked the mouse.

        private void SkinnedWindow_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                _offsetPoint = new Point(e.X, e.Y);
                _dragging = true;
            }
        }

In the MouseMove event we first check to see if we’re moving the window by checking the bool we set when the left button was clicked. If so then we’ll take a note of the current location of the mouse and convert that to a screen point.  We then set the form’s location to this new point which is the difference between this screen point and the original locaiton.

        private void SkinnedWindow_MouseMove(object sender, MouseEventArgs e)
        {
            if (_dragging)
            {
                Point mousePoint = new Point(e.X, e.Y);
                Point screenPoint = PointToScreen(mousePoint);
                Location = new Point(screenPoint.X - _offsetPoint.X, screenPoint.Y - _offsetPoint.Y);
            }
        }

When the user releases the left mouse button, we just need to note that we’re no longer moving the window by setting our flag to false.  Our form location is already where we want to leave the form.

        private void SkinnedWindow_MouseUp(object sender, MouseEventArgs e)
        {
            _dragging = false;
        }

If you run the program now, you’ll still see a gray window.  You can still right click and exit as before.  Now you can also move the form around. If you click inside the window and hold the mouse button down, you can drag the window around the screen. When you release the button the window will stay where it was.

In my application, I did not want the user to arbitrarily resize the window. In my application, I provided a context menu the user can select from a few predetermined sizes. When the user selects a size I set the size of the window using the Size property for the form. You could also do something similar to how we handled moving the window if you want to give the user more flexibility on resizing the window.

Step Three: The New Look

We’ve now implemented the basic functionality we’d lost so we can now focus on making the window look how we want. For this sample, I’m going to select an image from the Visual Studio image library.  I’m using the 007_PrintView_128x128_72.png image located in the library under Actions\png_format\WinVista. You can be any image, but for simplicity it should be a format that natively supports transparency for areas that are not part of the image.

clip_image004

First add the image to our project as a resource. To do this, go to the Project’s properties and select the Resources tab. Select Add Resource -> Add Existing File…. In the dialog that opens find and select the image that you wish to use for your application’s appearance. You will see a new Resources folder appear in the project and our graphic will appear under it. We can now reference this resource in our program when we want to draw the image.

In our case we want our entire window to appear as this image. Since the image I am using is 128 x 128 and I am not going to let the user resize the window, I will set the window on startup to this size. I can do this by going to the Properties of the form and setting the size to 128, 128 which the window the form to same size as the graphic that I’m using.

clip_image005

I will use this graphic as my window.  To give my form this custom look I implement the Paint event of the form.  In the Paint event, I first load the image. Here I’m doing it from the image resource.  You could also add the image as a file in the project and create the image from that file.

The code below will always resize the image to fill the window.  It changes a few settings to improve the quality of the resizing.  Since we above set our window size to 128 x 128, the same as the image, no resizing will be needed.  To see the effect of this, you can change the size of the window to a different value and the image will be scaled appropriately.

        private void SkinnedWindow_Paint(object sender, PaintEventArgs e)
        {
            // Get Image from resources
            using (Image folderImage = Resources.Network)
            {
                // Set to high quality and draw image onto background
                e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                e.Graphics.DrawImage(folderImage, 0, 0, Width, Height);
            }
        }

We’re almost there.  If we run the application now our window appears.  We see our graphic, but they gray background from the form still shows.

clip_image006

Our last step is to get rid of the form background. We do this by setting the background color of the form to a know value. By default it is set to the Control value which can be changed by the user if they customize the appearance of Windows or use a Windows Theme. Since we want our form background to always be transparent we’ll change this to a known value. The form property we need to change is BackColor and here I’m changing the value to white.

clip_image007

Next we want to set the TransparencyKey property to match this new BackColor property. This property tells Windows to treat any part of the form that is this color as transparent and let whatever lies under it show through.

clip_image008

After this change when we run our application, we get a nice transparent window that looks just like our image. Below you can see the image placed on top of Visual Studio 2010. Notice that the transparent parts of the image are not considered part of the form. If we right click or left click and drag in the top right area just above the printer, it does not register as a click on our form and will bring up the application behind ours.

clip_image009

You can download a sample project with this code for VS 2010 .

April 5, 2012

My First Article Posted for Windows.Appstorm

Filed under: article,web — Tags: , , — Bill Morefield @ 9:41 pm

I’m now writing articles for the Windows side of the Appstorm family of sites.  My first article is published and is a look at some changes and new features in the Photoshop CS6 beta.

http://windows.appstorm.net/reviews/photoshop-cs-6-what-you-need-to-know/

March 31, 2012

What are You Sharing?

Filed under: social networks — Tags: , , , — Bill Morefield @ 11:33 am

Late this week another social networking privacy problem came to light.  On Friday the web site Cult of Mac published a post about an app called Girls Around Me.  The application pulls data from social sites such as Facebook and Foursquare and combines them and would show you quite a bit of information about the people around you (though not just women as the name suggests).  I say “would” because Foursquare shut the app’s access down after the publicity.

This app wasn’t really doing anything that violated any rules.  All the data was freely available from the web sites involved and had been set to be public.  The creepy activities described in the article were doable before the app and still doable now the app has effectively been shut down.  This app just made it a lot easier.

In my post about social networks late last year I mostly discussed the problem of mapping real world relationships to the neat buckets of these sites.  Not directly mentioned in that post was the role of the world.  Those are the people that you don’t know.  The problem isn’t this app, it’s the fact that a lot of people don’t realize how much they are sharing to the world.

Social media apps work by sharing.  Without any sharing they are useless.  You sharing brings more users to the site.  You sharing gives more information they can turn around and sell to advertisers.  You sharing makes them money.  You sharing everything with everyone is therefore the default.  Every tweet, every status update, every check in, and every pin.  You can change the settings to be more private on every site.  Most people don’t know this, and many don’t care.

Think about what you share.  If you choose to share everything about your life, that’s fine and perhaps even noble.  I do hide a few items for various reasons on these sites.  The point is to think about it.  Don’t accept the defaults blindly.  Share what you want with who you want.

February 3, 2012

Adding Recovery Partition to Lion Install

Filed under: apple,osx — Tags: , , , — Bill Morefield @ 8:00 am

As I mentioned in an earlier Mac post, I upgraded my MacBook Pro with a larger 500 GB hard drive.  I made the move by cloning my existing hard drive to the new hard drive which I’d attached by USB.  This worked perfectly – until I went to encrypt the new drive.  It turns out my clone tool didn’t copy the hidden recovery partition.

I’m a big believer that any notebook or portable computer should be encrypted.  My previous PC was encrypted using Truecrypt which worked wonderfully.  When I moved to the Mac, I was happy to see Lion added support for real encryption.  I did that soon after upgrading to Lion with no problems.

I like encryption because I consider my data the most valuable things I have.  I don’t want to lose my hardware, but I really don’t want someone else able to flip through my data.  I try to keep the really important stuff off my laptop, but you never know what might slip onto it.  I like the thought that if my notebook is lost or stolen I can simply get my data back from the last backup while the thief can’t find anything.

When I went to encrypt the new hard drive, Mac OS informed me it couldn’t because the recovery partition was missing.  Some research led me to backing up my data to an external hard drive, and then doing an install and restore.  I did this, but apparently missed a step and still no recovery partition after almost a day of backup/install/restore.

I had some other tasks to work, on so I put this one off for a while.  I finally came back to this week.  My research led me to a blog post by Dmitry Dulepov that outlined a fairly straightforward process.  You install Lion to a USB drive, repartition your hard drive to create space for the recovery partition, and then copy the recovery partition from the USB drive to the hard drive.  I had a USB thumb drive that worked fine.  When I finished all went well until I looked for the recovery partition on the USB drive and didn’t see one.  Apparently this recovery partition is harder to create that I’d thought.

More reading showed me a couple more options.  First came trying to re-run the installer.  While that might have worked, I was a little wary given my track record with the installer not creating this partition.  So I did some more research which led me to this blog post on removing and rebuilding the recovery partition that referenced this entry.  I didn’t need to remove, but I did need to rebuild.  I skipped the removal of the partition in that first entry and followed the steps to rebuild it.  It worked.  I rebooted to find the recovery partition there and was immediately able to encrypt the drive.

February 1, 2012

Enable/Disable Root in Mac OSX

Filed under: apple — Tags: , — Bill Morefield @ 6:15 pm

Just to make it easier to find later. How to enable/disable root user in OS X Lion.

January 29, 2012

Boulevard of Dreams

Filed under: web — Tags: — Bill Morefield @ 12:36 pm

Yesterday I received an email reminding me that a domain name that I’d registered last February expires soon. Logging in to renew presents me with a list of all the domains I have.  It’s a bit like walking down memory lane, the online equivalent of visiting somewhere you used to live. The domains range from my first domain registered back in the late 1990’s, and still live though not updated in a couple years. Most are in use and supporting live web sites for myself or for clients that I’ve consulted with.

More interesting are those just sitting there at the moment. I’ve learned to register a domain name when I get an idea after finding one no longer available when I went back a few years ago. Some are registered for projects on that someday/maybe list.  These are the ones I’ll get to when time and priorities allow. Others remind me of projects that never came to pass. There’s a photography project that didn’t come about, but I later reused for something entirely different.  There’s a side business that didn’t work out.  Most are sitting there waiting for the day when they’ll be needed.

Some I wonder if I’ll ever use.  A project I investigated a few years has little chance of coming to anything, but I still keep the domain name just in case.  I’ve been surprised sometimes when an old name suddenly becomes useful.  As I mentioned, a photography project that didn’t work out left me with a domain name that sat idle for a couple years before working perfectly for a completely different project last spring.

I also don’t let domains go because of a lesson from a friend. She owned a domain that she let expire. It was immediately snapped up by someone else and she’s not had the chance to get it back. There are ways to get them back, but the time and cost are not trivial and she’s never felt the urgency to pursue it.  Still not having the domain limited her options and I don’t want to wind up in that same place.

In the end those unused domains are options.  Having them gives me options and I like that.

« Newer PostsOlder Posts »

Powered by WordPress