<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cory Plotts' Blog &#187; RepeatButton</title>
	<atom:link href="http://www.cplotts.com/tag/repeatbutton/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cplotts.com</link>
	<description>Yet another UX guy, working in WPF/Silverlight.</description>
	<lastBuildDate>Tue, 15 Nov 2011 21:22:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Make System.Windows.Forms.Button into a RepeatButton</title>
		<link>http://www.cplotts.com/2008/12/10/make-systemwindowsformsbutton-into-a-repeatbutton/</link>
		<comments>http://www.cplotts.com/2008/12/10/make-systemwindowsformsbutton-into-a-repeatbutton/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 15:42:19 +0000</pubDate>
		<dc:creator>cplotts</dc:creator>
				<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[RepeatButton]]></category>

		<guid isPermaLink="false">http://www.cplotts.com/?p=23</guid>
		<description><![CDATA[Recently, I was trying to get caught up on my blog reading and read Scott Hanselman&#8217;s blog post about SyntaxHighlighter. Well, this encouraged me to install Windows Live Writer and try this plugin out. (I was always bothered that I had to create pngs with my code snippets in them for my blog post on [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I was trying to get caught up on my blog reading and read Scott Hanselman&#8217;s blog <a href="http://www.hanselman.com/blog/BestCodeSyntaxHighlighterForSnippetsInYourBlog.aspx">post</a> about <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">SyntaxHighlighter</a>. Well, this encouraged me to install Windows Live Writer and try this plugin out. (<em>I was always bothered that I had to create pngs with my code snippets in them for my blog post on name scopes in WPF.</em>)</p>
<p>Well, I quickly found out that a blog at <a href="http://www.wordpress.com">www.wordpress.com</a> can not use plugins. Argh. So, I finally broke down, decided to register a domain, and installed WordPress to it.</p>
<p>So, this post is really a test of whether I have correctly set up Alex Gorbatchev&#8217;s SyntaxHighlighter, but I thought I would go ahead and post something interesting as well. So, without further adieu:</p>
<p>Recently, I thought &#8230; &#8220;I love WPF&#8217;s RepeatButton. How can I make the System.Windows.Forms.Button into a RepeatButton?&#8221;</p>
<p>So here is some code to do that:</p>
<pre class="brush: csharp">public class RepeatButton : System.Windows.Forms.Button
{
    protected override void OnMouseDown(MouseEventArgs e)
    {
        base.OnMouseDown(e);

        if (e.Button == MouseButtons.Left)
        {
            OnClick(EventArgs.Empty);
            RepeatButton.repeatButtonTimer.Tick += new EventHandler(repeatButtonTimer_Tick);
            repeatButtonTimer.Start();
        }
    }
    protected override void OnMouseUp(MouseEventArgs e)
    {
        this.mousingUp = true;

        base.OnMouseUp(e);

        if (e.Button == MouseButtons.Left)
        {
            repeatButtonTimer.Stop();
            RepeatButton.repeatButtonTimer.Tick -= new EventHandler(repeatButtonTimer_Tick);
        }

        this.mousingUp = false;
    }

    protected override void OnClick(EventArgs e)
    {
        if (this.mousingUp) return;

        base.OnClick(e);
    }

    private void repeatButtonTimer_Tick(object sender, EventArgs e)
    {
        OnClick(EventArgs.Empty);
    }

    private bool mousingUp = false;

    static RepeatButton()
    {
        repeatButtonTimer.Interval = 250;
    }
    private static System.Windows.Forms.Timer repeatButtonTimer = new Timer();
}</pre>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.cplotts.com%2F2008%2F12%2F10%2Fmake-systemwindowsformsbutton-into-a-repeatbutton%2F&amp;title=Make%20System.Windows.Forms.Button%20into%20a%20RepeatButton" id="wpa2a_2">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.cplotts.com/2008/12/10/make-systemwindowsformsbutton-into-a-repeatbutton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

