Monday, January 23, 2012

Ratcheting up the scroll with my Logitech mouse

With the PC that gets used by the family, we use a wireless Logitech mouse. It’s the VX Revolution. It’s a few years old, but it has all the functionality that we need.

vx-revolutionI was using it tonight and the scrolling was, for the lack of a better word, wrong.  The wheel usually scrolled with a nice ratchet.  You moved the wheel, and you would feel a nice soft click as it scroll.

Tonight, it had stopped clicking and the scrolling was too sensitive.  You would scroll down a page and when you lifted your finger off the mouse wheel, it would roll back a tiny bit.  This would cause the page on the screen to jump back a bit.  It was very jarring and annoying.  What did I do to this thing and how do I fix it?

On my home dev box, I have a Logitech MX Revolution.  Kind of like the big brother to the VX.  On the MX, I could switch the wheel between the free spinning mode and the ratchet mode by clicking on the wheel.  That didn’t work on the VX.  I tried playing with the Logitech SetPoint utility that allows you to tweak the mouse settings.  No dice, nothing jumped out.

When in doubt, see if there is an updated mouse driver from Logitech.  I had 6.2 installed, the current version is 6.3.  So I grabbed the general Windows 7 setup exe for SetPoint and installed.  And that’s when the Logitech driver fell down.  Their all in one installer installed the 32 bit driver instead of the 64 bit driver.  Usually that’s not a huge deal, but it looked like they installed the 32 driver AS the 64 bit driver.  It crashed as soon as I loaded it.

OK, back to square one.  I uninstalled the newly broken driver and when back to the Logitech site.  Sure enough, I saw a link for the 64 bit only version.  I grabbed it, installed it, and it ran with out crashing.  It didn’t let me change the scroll wheel behavior, so I was back to square one again.

When in doubt, RTFM.  I took a peek at the user guide for the VX, from the Logitech site.  Guess what gang, on the bottom of the mouse, there’s an oddly shaped switch control.

OddlyShapedFigure 1 – An oddly shaped control

It’s hard to see in this picture, but the smooth circle at the top right of the switch puts the mouse into free wheel mode.  The gear shape at the bottom left, puts the mouse in ratchet.  Somehow the switch had been changed to free rolling mode.  I flicked back to ratchet mode and life was good again.

Saturday, January 14, 2012

An open letter to Newport Television

This is a copy of an email that I just sent to Newport Television, owners of WXXA-FOX23

Please forward to Michael DiPasquale, Vice-President/Asst. General Counsel at Newport Television

Dear Mr. DiPasquale,

I am a Verizon FiOS subscriber in the Albany, NY area.  I have noticed that you have pulled WXXA-FOX23 from Verizon FiOS TV because your carriage agreement expired on January 12, 2012.  My understanding of this is that your company, Newport Television, and Verizon could not come to an agreement over the rates.

As someone who watches WXXA, I am one of your customers.  As such, I would like to share my opinion.  I don't know the details of your carriage rate negotiations, but I think you should settle with Verizon. 

I don't want to pay more for a channel that I can get over the air (OTA).  The FOX network programming that I watch is mostly available via the FiOS Video On Demand (VOD) service.  I won't get to see the show when it airs, but I'll see it within a week.  And it will be commercial free.  I like my DVR, I watch TV on my schedule. 

With your channel being OTA only, the only time I'm going to watch it is going to be for sports. I liked watching the FOX23 news, that was one of the few shows you had my attention through commercials.  And that was the same for FOX sports.  I can put up with the annoyance of switching to the OTA signal for the sports, but for the rest of your coverage, I'll just skip it.

FiOS coverage is still small in the Albany area, but the areas with FiOS availability tend to be the higher income areas.  We are the people that your advertisers want to reach.  You have better access to the subscriber numbers, but I would expect that you are no longer available in 10,000 household in middle to upper middle class neighborhoods in this area.  If I were an advertiser with you, I would be negotiating for a lower rate on commercial air time.

I don't know the detail of your negotiations with Verizon, but if you are asking for a higher rate, I really think that you should reconsider your terms.  I don't know the state of the local economy is in Kansas City, MO; but it's not that great here.  Please consider this during your negotiations with Verizon FiOS.

sincerely,
Chris Miller
Slingerlands, NY

Thursday, November 10, 2011

Replacing GetHostByName with GetHostAddresses

I’m working on some C# code that needs to send some data over a socket connection.  The user can specify the destination by name or by IP address.  I was using syntax like the following to get the address

IPAddress addr = Dns.GetHostByName(host).AddressList[0];

IPEndPoint endPoint = new IPEndPoint(addr, 9100);


That worked, but VS2010 spits out the following warning:

'System.Net.Dns.GetHostByName(string)' is obsolete: '"GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202"'   

So I replaced the call to GetHostByName with GetHostEntry. When I passed in the IP address as a string GetHostByName, it threw an error, "No such host is known".

That's not good. I didn't want to use obsolete code, but the recommended replacement wasn't working. I did a bit of searchnng on the Internets and found that GetHostEntry attempts to do a DNS reverse resolve and that doesn't always work. As it turns out, GetHostEntry is not the only method that can be substituted for GetHostByName. GetHostAddresses will return the IP address for the specified host. I was able to use the following code without any warnings:



IPAddress addr = Dns.GetHostAddresses(host)[0];

IPEndPoint endPoint = new IPEndPoint(addr, 9100);

And we are good.


Friday, September 30, 2011

An odd way to post

This short little post was composed with the Blogger iPhone app. It's running on my iPad and I'm using the BlueTooth keyboard that HP made for the ill-fated TouchPad.

It works, but I'm limited to basic text entry. No fancy HTML was harmed in the making of this post. You can include images, which is something I guess. I would have liked an app that let you enter in HTML markup using something like markdown.

On the plus side, the HP keyboard is nice way to enter in extended amounts of text on a touch only device. Most of the keys work. The media keys work just fine, but most of the TouchPad specific keys are ignored. With the exception of the search key, that invokes the iOS search box. For $20, it's a good enough BT keyboard for my needs. It's HID enough.

I went back and edited this post with an app called, BlogPress. It's not Windows Live Writer, but it's good enough for posting from a tablet. You can do some basic HTML formatting. It's a bit quirky, especially when scrolling at the bottom of the page. The text looks like it's dropping of the bottom of the page and you have to drag the page back up. But it works.

Location:Home,United States

Wednesday, July 13, 2011

How to set the DevExpress ASPxScheduler current time line marker to only appear for the current date

I’ve been using the DevExpress ASPxScheduler with one of our WebForms apps and it’s been a pretty good experience so far. It does pretty much what I need for it to do and I have been able to bend it to do things that I want it to do.

One feature is that it displays a marker on the scheduler to represent the current time.  This is a feature that Outlook does on its calendar and the ASPxScheduler by and large is trying to mirror that experience.  In this case, they behave slightly differently than Outlook.  In Outlook, the time line marker only appears when the calendar time span includes the current date.  If the calendar view does not include the current date, you don’t see that line.

(Image of the scheduler control showing the time marker taken from the online documentation)

With the ASPxScheduler, if you have time line marker enabled, it’s always being displayed, no matter what the date is.  That is a little bit counter intuitive and doesn’t match the Outlook model that DevExpress is trying to following.  As it turns out, it was easy to change that behavior.

You can use the VisibleIntervalChanged event of ASPxScheduler control and make the time line marker behave like Outlook with a single line of code:

protected void ASPxScheduler1_VisibleIntervalChanged(object sender, EventArgs e)
{
ASPxScheduler1.OptionsBehavior.ShowTimeMarker = ASPxScheduler1.ActiveView.GetVisibleIntervals().Interval.Contains(DateTime.UtcNow.Date.AddMinutes(1));
}


We use this event to enable the display of the marker when the current date is being displayed by the control, otherwise disable the marker. The call to GetVisibleIntervals().Interval returns TimeInterval object, which is a DevExpress.XtraScheduler class that represents an interval of time for the current scheduler view.  You can use the Contains() method to check if a DateTime or TimeInterval object is contained within the interval.  Internally, the ASPxScheduler uses UTC time, so you want to pass the current date as UTC.  We add 1 minute to the time otherwise the DayView for the previous day will include the current date.



This functionality works for the version of the ASPxScheduler that was current at the time this was written, v2011.1.5.

Wednesday, June 08, 2011

Binding an Enum to a DataSource

I had some code for an ASP.Net Webforms app where I need to present to the user a list of options that were define as Enum.  I want to populate a combobox with the enumerated type values and do it from code automatically.  This is the Enum in question

enum PrintColorSchema {
Default = 0,
FullColor = 1,
GrayScale = 2,
BlackAndWhite = 3,
}


To make things more interesting, I wanted to exclude the first item in the list, “Default”.  One way to do this would be to manually populate a select list with the values from the Enum.  While that would work for this Enum, I wanted to find a way where I didn’t have to hard code the values.

I added a DropDownList control to the page and in the code behind, I added the following code:

ColorSchema.DataSource = 
Enum.GetValues(typeof(PrintColorSchema))
.Cast<PrintColorSchema>()
.Select(en => new
{
Value = en,
Text = Wordify(en.ToString())
}).Where (en => en.Value != PrintColorSchema.Default);

ColorSchema.DataTextField = "Text";
ColorSchema.DataValueField = "Value";
ColorSchema.DataBind();

What we are using is a bit of LINQ to convert the Enum to an IEnumerable collection of an anonymous class. That class has two members, Value and Text. Value is set to the enumerated type and Text is set to prettified version of the enumerated type. That function looks like this:

public static string Wordify(string pascalCaseString)
{
System.Text.RegularExpressions.Regex r =
new System.Text.RegularExpressions.Regex("(?<=[a-z])(?[A-Z])|(?<=.)(?[A-Z])(?=[a-z])");
return r.Replace(pascalCaseString, " ${x}");
}

The code

Enum.GetValues(typeof(PrintColorSchema))

converts the Enum to an array of constants. The next part

.Cast<PrintColorSchema>()

returns an IEnumerable collecttion from the array. The code

.Select(en => new
{
Value = en,
Text = Wordify(en.ToString())
})

returns a new IEnumerable<> collection of an anonymouse type. That type has the enumeration element as the Value and that element converted to a string as the Text. Since the elements were in "PascalCase", a simple RegEx function was used to split the text into multiple words, The final Where operator is used to filter out the first item from the list.

The HTML that gets rendered:

<select id="ColorSchema" name="ColorSchema"> 
<option selected value="FullColor">Full Color</option>
<option value="GrayScale">Gray Scale</option>
<option value="BlackAndWhite">Black And White</option>
</select>

Which renders like this



For this Enum, all the code was overkill, adding three <option> elements to the <select> control would have been less work.  Where this is handy is when you have Enum types with many elements or when the Enum type changes.  If the Enum type changes, no modification to your code is needed to update the combo box.  One less place in the code to fail.  And that is a good thing.

Tuesday, May 03, 2011

There was a Time Warner Cable Disconnect Technician in my yard this morning.

I had an interesting conversation this morning with a Time Warner Cable (TWC) Disconnect Technician.  I went out to get my paper and he had the cable junction box open.  He was clipping the wires going my house and my neighbor’s house.  We had both switched to Verizon FiOS TV and were no longer paying for any TWC services.

He came over to me and asked if he could ask a few questions.  I wasn’t sure what to expect, but he was very friendly.  He is a Disconnect Technician. He was driving all over town, clipping the cable wires to houses that had switched from TWC to FiOS.  Since FiOS TV went live in Bethlehem last month, TWC was bleeding customers all over town.  He didn’t give me any numbers, but he said a lot of people had already switched and TWC management are pretty upset.

He is also a disgruntled ex-employee of TWC.  At one point he was a TWC employee with the full benefits, at some point they terminated his position and hired him back as a contractor to TWC.  He was not happy about the change from being an employee to being a contractor.  He wasn’t the only employee that they did this to, it must have been a cost cutting move on TWC’s part.

He asked me about the services that I was getting and how much I was paying. Oddly enough, he though I was getting the TV channels through a dish.  He literally didn’t know that FiOS TV was a Verizon package of channels.  He said that he was thinking of getting FiOS service for himself.

He did say a few times that the local TWC management were upset over the subscribers losses to Verizon.  They don’t have much to offer existing subscribers who want to switch.  They can’t compete on the technology side, but they can compete on the cost.  Raising their rates a month before FiOS TV rolled into town, was not one of their smarter moves.

When I went to the local TWC office to cancel my service and return the equipment, the staff there made no attempt to keep me as a customer.  They asked where I was moving to, and they were surprised when I said I wasn’t moving.  But they did not ask why I was dropping the service or ask if there was anything that they could do to get me to stay with TWC.   It would have been a pointless effort, I was already on FiOS TV and there was nothing that TWC could offer to get me to switch back.  Still, it’s general business sense to keep your existing customers.