Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear click type OneTouch #621

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Helios/Controls/ClickType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,22 @@ public enum LinearClickType

[Description("Swipe over the control in the direction it should move")]
Swipe,

[Description("Touch the control anywhere to switch it")]
OneTouch,
}

/// <summary>
/// interaction styles for linear controls that require a direction to work
///
/// WARNING: these value names must never be changed, as they are serialized to Profile XML
/// </summary>
public enum LinearClickTypeDirectional
{
[Description("Touch the location towards which the control should move")]
Touch,

[Description("Swipe over the control in the direction it should move")]
Swipe,
}
}
2 changes: 1 addition & 1 deletion Helios/Controls/GuardedSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public override void MouseDown(Point location)
_mouseDownLocation = location;
_mouseAction = false;
}
else if (ClickType == LinearClickType.Touch)
else if (ClickType == LinearClickType.Touch || ClickType == LinearClickType.OneTouch)
{
switch (GuardPosition)
{
Expand Down
31 changes: 31 additions & 0 deletions Helios/Controls/GuardedThreeWayToggle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,37 @@ public override void MouseDown(Point location)
break;
}
}

else if (ClickType == LinearClickType.OneTouch)
{
switch (GuardPosition)
{
case GuardPosition.Up:
if (_guardUpRegion.Contains(location))
{
GuardPosition = Controls.GuardPosition.Down;
}
else if (_switchRegion.Contains(location))
{
switch (SwitchPosition)
{
case ThreeWayToggleSwitchPosition.Three:
SwitchPosition = ThreeWayToggleSwitchPosition.One;
break;
default:
++SwitchPosition;
break;
}
}
break;
case GuardPosition.Down:
if (_guardDownRegion.Contains(location))
{
GuardPosition = Controls.GuardPosition.Up;
}
break;
}
}
}

public override void MouseDrag(Point location)
Expand Down
31 changes: 31 additions & 0 deletions Helios/Controls/GuardedToggleSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,37 @@ public override void MouseDown(Point location)
break;
}
}

else if (ClickType == LinearClickType.OneTouch)
{
switch (GuardPosition)
{
case GuardPosition.Up:
if (_guardUpRegion.Contains(location))
{
GuardPosition = Controls.GuardPosition.Down;
}
else if (_switchRegion.Contains(location))
{
switch (SwitchPosition)
{
case ToggleSwitchPosition.Two:
SwitchPosition = ToggleSwitchPosition.One;
break;
default:
++SwitchPosition;
break;
}
}
break;
case GuardPosition.Down:
if (_guardDownRegion.Contains(location))
{
GuardPosition = Controls.GuardPosition.Up;
}
break;
}
}
}

public override void MouseDrag(Point location)
Expand Down
6 changes: 6 additions & 0 deletions Helios/Controls/KneeboardSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ protected override void ThrowSwitch(ToggleSwitchBase.SwitchAction action)
case KneeboardSwitchPosition.Two:
SwitchPosition = KneeboardSwitchPosition.Three;
break;
default:
SwitchPosition = KneeboardSwitchPosition.One;
break;
}
}
else if (action == SwitchAction.Decrement)
Expand All @@ -314,6 +317,9 @@ protected override void ThrowSwitch(ToggleSwitchBase.SwitchAction action)
case KneeboardSwitchPosition.Three:
SwitchPosition = KneeboardSwitchPosition.Two;
break;
default:
SwitchPosition = KneeboardSwitchPosition.One;
break;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions Helios/Controls/Metric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class Metric : HeliosVisual
private bool _mouseDown = false;
private Point _mouseDownLocation;

protected LinearClickType _clickType = LinearClickType.Swipe;
protected LinearClickTypeDirectional _clickType = LinearClickTypeDirectional.Swipe;
private CalibrationPointCollectionDouble _swipeCalibration;
private double _swipeThreshold = 10;
private double _sensitivity = 0d;
Expand All @@ -44,7 +44,7 @@ protected Metric ( string name, Size defaultSize )

#region Properties

public LinearClickType ClickType
public LinearClickTypeDirectional ClickType
{
get
{
Expand All @@ -54,7 +54,7 @@ public LinearClickType ClickType
{
if ( !_clickType.Equals( value ) )
{
LinearClickType oldValue = _clickType;
LinearClickTypeDirectional oldValue = _clickType;
_clickType = value;
OnPropertyChanged( "ClickType", oldValue, value, true );
}
Expand Down Expand Up @@ -242,7 +242,7 @@ private double GetAngle ( Point startPoint, Point endPoint )

public override void MouseDown ( Point location )
{
if ( _clickType == LinearClickType.Touch )
if ( _clickType == LinearClickTypeDirectional.Touch )
{
if ( _clickableVertical )
{
Expand All @@ -268,7 +268,7 @@ public override void MouseDown ( Point location )
// Parent.Profile.ProfileTick += new EventHandler( Profile_ProfileTick );
//}
}
else if ( _clickType == LinearClickType.Swipe )
else if ( _clickType == LinearClickTypeDirectional.Swipe )
{
_mouseDown = true;
_mouseDownLocation = location;
Expand Down Expand Up @@ -301,7 +301,7 @@ void Profile_ProfileTick ( object sender, EventArgs e )

public override void MouseDrag ( Point location )
{
if ( _mouseDown && _clickType == LinearClickType.Swipe )
if ( _mouseDown && _clickType == LinearClickTypeDirectional.Swipe )
{
if ( DragOneForOne )
{
Expand Down
6 changes: 3 additions & 3 deletions Helios/Controls/PotentiometerWithTranslate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public override void WriteXml ( XmlWriter writer )

writer.WriteStartElement( "ClickType" );
writer.WriteElementString( "Type", ClickType.ToString( ) );
if ( ClickType == LinearClickType.Swipe )
if ( ClickType == LinearClickTypeDirectional.Swipe )
{
writer.WriteElementString( "Sensitivity", Sensitivity.ToString( CultureInfo.InvariantCulture ) );
}
Expand Down Expand Up @@ -723,7 +723,7 @@ public override void ReadXml ( XmlReader reader )
if ( reader.Name.Equals( "ClickType" ) )
{
reader.ReadStartElement( "ClickType" );
ClickType = (LinearClickType)Enum.Parse( typeof( LinearClickType ), reader.ReadElementString( "Type" ) );
ClickType = (LinearClickTypeDirectional)Enum.Parse( typeof( LinearClickTypeDirectional ), reader.ReadElementString( "Type" ) );
if (reader.Name == "Sensitivity")
{
Sensitivity = double.Parse( reader.ReadElementString( "Sensitivity" ), CultureInfo.InvariantCulture );
Expand All @@ -732,7 +732,7 @@ public override void ReadXml ( XmlReader reader )
}
else
{
ClickType = LinearClickType.Swipe;
ClickType = LinearClickTypeDirectional.Swipe;
Sensitivity = 0d;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Height="609.143" Width="176.5">
<HeliosSdk:HeliosPropertyEditor.Resources>
<Helios:EnumConverter Type="{x:Type HeliosBase:LinearClickType}" x:Key="ClickTypes" />
<Helios:EnumConverter Type="{x:Type HeliosBase:LinearClickTypeDirectional}" x:Key="ClickTypes" />

<Style x:Key="NoTouchStyle" TargetType="FrameworkElement">
<Style.Triggers>
Expand Down
6 changes: 6 additions & 0 deletions Helios/Controls/ThreeWayToggleSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ protected override void ThrowSwitch(ToggleSwitchBase.SwitchAction action)
case ThreeWayToggleSwitchPosition.Two:
SwitchPosition = ThreeWayToggleSwitchPosition.Three;
break;
default:
SwitchPosition = ThreeWayToggleSwitchPosition.One;
break;
}
}
else if (action == SwitchAction.Decrement)
Expand All @@ -311,6 +314,9 @@ protected override void ThrowSwitch(ToggleSwitchBase.SwitchAction action)
case ThreeWayToggleSwitchPosition.Three:
SwitchPosition = ThreeWayToggleSwitchPosition.Two;
break;
default:
SwitchPosition = ThreeWayToggleSwitchPosition.One;
break;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Helios/Controls/ToggleSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ protected override void ThrowSwitch(SwitchAction action)
case ToggleSwitchPosition.One:
SwitchPosition = ToggleSwitchPosition.Two;
break;
default:
SwitchPosition = ToggleSwitchPosition.One;
break;
}
}
else if (action == SwitchAction.Decrement)
Expand All @@ -247,6 +250,9 @@ protected override void ThrowSwitch(SwitchAction action)
case ToggleSwitchPosition.Two:
SwitchPosition = ToggleSwitchPosition.One;
break;
default:
SwitchPosition = ToggleSwitchPosition.One;
break;
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions Helios/Controls/ToggleSwitchBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace GadrocsWorkshop.Helios.Controls
{
using System;
using System.Windows;

public abstract class ToggleSwitchBase : HeliosVisual
Expand Down Expand Up @@ -192,6 +193,12 @@ public override void MouseDown(Point location)
_mouseAction = true;
}
}

else if (ClickType == LinearClickType.OneTouch)
{
ThrowSwitch(SwitchAction.Increment);
_mouseAction = true;
}
}

public override void MouseDrag(Point location)
Expand Down