Tastudio - make < and > buttons repeatable buttons

This commit is contained in:
adelikat 2015-02-24 21:44:26 +00:00
parent 6a02656417
commit 8af99c9066
3 changed files with 124 additions and 24 deletions

View File

@ -495,6 +495,9 @@
<Compile Include="CustomControls\QuickProgressPopup.Designer.cs">
<DependentUpon>QuickProgressPopup.cs</DependentUpon>
</Compile>
<Compile Include="CustomControls\RepeatButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\TransparentTrackbar.cs">
<SubType>Component</SubType>
</Compile>

View File

@ -0,0 +1,93 @@
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk
{
// http://www.codeproject.com/Articles/2130/NET-port-of-Joe-s-AutoRepeat-Button-class
public class RepeatButton : Button
{
private Timer m_timer;
private bool down = false;
private bool once = false;
private int m_initdelay = 1000;
private int m_repdelay = 400;
public RepeatButton()
{
this.MouseUp +=
new MouseEventHandler(RepeatButton_MouseUp);
this.MouseDown +=
new MouseEventHandler(RepeatButton_MouseDown);
m_timer = new Timer();
m_timer.Tick += new EventHandler(timerproc);
m_timer.Enabled = false;
}
private void timerproc(object o1, EventArgs e1)
{
m_timer.Interval = m_repdelay;
if (down)
{
once = true;
this.PerformClick();
}
}
protected override void OnClick(EventArgs e)
{
if (!once || down)
base.OnClick(e);
}
private void RepeatButton_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
m_timer.Interval = m_initdelay;
m_timer.Enabled = true;
down = true;
}
private void RepeatButton_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
m_timer.Enabled = false;
down = false;
}
public int InitialDelay
{
get
{
return m_initdelay;
}
set
{
m_initdelay = value;
if (m_initdelay < 10)
m_initdelay = 10;
}
}
public int RepeatDelay
{
get
{
return m_repdelay;
}
set
{
m_repdelay = value;
if (m_repdelay < 10)
m_repdelay = 10;
}
}
}
}

View File

@ -33,10 +33,10 @@
this.TurboSeekCheckbox = new System.Windows.Forms.CheckBox();
this.FollowCursorCheckbox = new System.Windows.Forms.CheckBox();
this.NextMarkerButton = new System.Windows.Forms.Button();
this.FrameAdvanceButton = new System.Windows.Forms.Button();
this.PauseButton = new System.Windows.Forms.Button();
this.RewindButton = new System.Windows.Forms.Button();
this.PreviousMarkerButton = new System.Windows.Forms.Button();
this.FrameAdvanceButton = new BizHawk.Client.EmuHawk.RepeatButton();
this.RewindButton = new BizHawk.Client.EmuHawk.RepeatButton();
this.PlaybackGroupBox.SuspendLayout();
this.SuspendLayout();
//
@ -103,16 +103,6 @@
this.NextMarkerButton.UseVisualStyleBackColor = true;
this.NextMarkerButton.Click += new System.EventHandler(this.NextMarkerButton_Click);
//
// FrameAdvanceButton
//
this.FrameAdvanceButton.Location = new System.Drawing.Point(117, 19);
this.FrameAdvanceButton.Name = "FrameAdvanceButton";
this.FrameAdvanceButton.Size = new System.Drawing.Size(38, 23);
this.FrameAdvanceButton.TabIndex = 3;
this.FrameAdvanceButton.Text = ">";
this.FrameAdvanceButton.UseVisualStyleBackColor = true;
this.FrameAdvanceButton.Click += new System.EventHandler(this.FrameAdvanceButton_Click);
//
// PauseButton
//
this.PauseButton.Location = new System.Drawing.Point(80, 19);
@ -123,16 +113,6 @@
this.PauseButton.UseVisualStyleBackColor = true;
this.PauseButton.Click += new System.EventHandler(this.PauseButton_Click);
//
// RewindButton
//
this.RewindButton.Location = new System.Drawing.Point(43, 19);
this.RewindButton.Name = "RewindButton";
this.RewindButton.Size = new System.Drawing.Size(38, 23);
this.RewindButton.TabIndex = 1;
this.RewindButton.Text = "<";
this.RewindButton.UseVisualStyleBackColor = true;
this.RewindButton.Click += new System.EventHandler(this.RewindButton_Click);
//
// PreviousMarkerButton
//
this.PreviousMarkerButton.Location = new System.Drawing.Point(6, 19);
@ -143,6 +123,30 @@
this.PreviousMarkerButton.UseVisualStyleBackColor = true;
this.PreviousMarkerButton.Click += new System.EventHandler(this.PreviousMarkerButton_Click);
//
// FrameAdvanceButton
//
this.FrameAdvanceButton.InitialDelay = 500;
this.FrameAdvanceButton.Location = new System.Drawing.Point(117, 19);
this.FrameAdvanceButton.Name = "FrameAdvanceButton";
this.FrameAdvanceButton.RepeatDelay = 50;
this.FrameAdvanceButton.Size = new System.Drawing.Size(38, 23);
this.FrameAdvanceButton.TabIndex = 3;
this.FrameAdvanceButton.Text = ">";
this.FrameAdvanceButton.UseVisualStyleBackColor = true;
this.FrameAdvanceButton.Click += new System.EventHandler(this.FrameAdvanceButton_Click);
//
// RewindButton
//
this.RewindButton.InitialDelay = 1000;
this.RewindButton.Location = new System.Drawing.Point(43, 19);
this.RewindButton.Name = "RewindButton";
this.RewindButton.RepeatDelay = 100;
this.RewindButton.Size = new System.Drawing.Size(38, 23);
this.RewindButton.TabIndex = 1;
this.RewindButton.Text = "<";
this.RewindButton.UseVisualStyleBackColor = true;
this.RewindButton.Click += new System.EventHandler(this.RewindButton_Click);
//
// PlaybackBox
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
@ -159,9 +163,9 @@
private System.Windows.Forms.GroupBox PlaybackGroupBox;
private System.Windows.Forms.Button NextMarkerButton;
private System.Windows.Forms.Button FrameAdvanceButton;
private RepeatButton FrameAdvanceButton;
private System.Windows.Forms.Button PauseButton;
private System.Windows.Forms.Button RewindButton;
private RepeatButton RewindButton;
private System.Windows.Forms.Button PreviousMarkerButton;
private System.Windows.Forms.CheckBox AutoRestoreCheckbox;
private System.Windows.Forms.CheckBox TurboSeekCheckbox;