rulururu

post The Aaron and Mike Show #2

October 30th, 2008

Filed under: The Aaron and Mike Show — mike hall @ 3:10 pm

The second show is in the bag. Talked a little about PDC (which I knew very little about) and a little about Aaron’s upcoming trip. Check it out!

Streaming live video by Ustream

post I Have a Path.Combine, But How About a Url.Combine?

October 30th, 2008

Filed under: coding, programming — mike hall @ 1:41 am

If you’re wanting to combine two URLs with Path.Combine, then you’re likely to wind up with something like “http://bitterware.com\download.html”… and that’s not very good. What we need is something like a Url.Combine. Well, we have something like that. We have Uri.TryCreate, but it’s not as pretty as Path.Combine. So I prettied it up, wrapped it up and thought I’d share:

namespace Bitter
{
    namespace Path
    {
        public static class Url
        {
            public static string Combine(string domain, string page)
            {
                string combinedUrl = String.Empty;
                Uri baseUri = null;

                // create the URI object from the string domain
                try
                {
                    baseUri = new Uri(domain);
                }
                catch (Exception ex)
                {
                    baseUri = null;
                }

                // try to combine and create the new URI
                if (baseUri != null)
                {
                    Uri value = null;
                    if (Uri.TryCreate(baseUri, page, out value))
                        combinedUrl = value.ToString();
                }

                return combinedUrl;
            }

post The Aaron and Mike Show #1

October 24th, 2008

Filed under: The Aaron and Mike Show — mike hall @ 3:07 pm

Yesterday was a successful run (at least in our eyes) of our first show. The recording starts a few minutes in, pesky record button, but we have most of it. We have the video stored up on ustream in case you missed it. We’ll be broadcasting again next Thursday, so don’t miss it!!! Unless you have something to do… then watch the recorded version!!!

Streaming live video by Ustream

post Showing Administrator Shield on a Button

October 24th, 2008

Filed under: coding, programming — mike hall @ 12:38 pm

By now, I’m sure that everyone has seen the little shield image on a button or file:

We all know that it means that you need adminstrator rights, or to log in to an admin account in order to install something or perform some operation that only admins can do. Well recently I’ve been working on an install and on the auto-updating feature of Bitter, so I really wanted the ability to show this so that users immediately knew that it required admin rights. But how do you do this in C#? Well, of course, there’s no simple Button.ShowShield() method or anything as easy as that. You need to import a dll and then call a method with a certain constant. Fun, eh? Anyway, I wrapped all that into a class and thought I’d share. If anyone finds any bugs or improvements let me know. Enjoy!

class ShieldButton : Button
{
    [DllImport("user32.dll")]
    private static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

    // Define BCM_SETSHIELD locally, declared originally in Commctrl.h
    private const uint BCM_SETSHIELD = 0×0000160C;

    private bool m_useShield = true;

    protected override void OnCreateControl()
    {
        base.OnCreateControl();
        SetShield();
    }

    private void SetShield()
    {
        if (m_useShield)
        {
            // Set button style to the system style, else the shield image won’t show
            this.FlatStyle = FlatStyle.System;

            // Send the BCM_SETSHIELD message to the button control to show the shield image
            SendMessage(new HandleRef(this, this.Handle), BCM_SETSHIELD, new IntPtr(0), new IntPtr(1));
        }
        else
        {
            // Send the BCM_SETSHIELD message to the button control to hide the shield image
            SendMessage(new HandleRef(this, this.Handle), BCM_SETSHIELD, new IntPtr(0), new IntPtr(0));

            // Set button style back to the system style, since we removed the shield image
            this.FlatStyle = FlatStyle.Standard;
        }
    }

    public bool Enabled
    {
        get
        {
            return base.Enabled;
        }

        set
        {
            // need to hide the shield image before disabling, else it won’t disable properly
            m_useShield = value;
            SetShield();

            base.Enabled = value;
        }
    }
}

post The Aaron and Mike Show

October 23rd, 2008

Filed under: Uncategorized — mike hall @ 10:52 am

Aaron Lerch and I have started a new venture. No, it’s not "The Aaron and Mike Show". Ok, maybe it is. Basically we’re going to be talking tech and probably making fools of ourselves along the way. It’s being broadcast at 4pm EST live and we’ll keep the recordings around for later viewing. Check it out.

But there’s also been talk of The Mike and Aaron Show too. So stay tuned…

ruldrurd

Powered by WordPress, Theme based off the "I'm Okay" theme by Laurentiu Piron

Creative Commons License This work is licensed under a Creative Commons Attribution 3.0 United States License.


Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.