|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using FSA;
namespace FormsFSATest
{
class MovingObjectFSA
{
public enum Output
{
TakeCursor = 0,
NormalCursor = 1,
MoveCursor = 2
}
public enum States
{
Normal = 0,
OverObject = 1,
Moving = 2
}
public enum Input
{
MouseLeave = 0,
MouseEnter = 1,
MouseUp = 2,
MouseDown = 3,
MouseMove = 4,
}
private const int TABLE_SIZE = 8;
public static FiniteStateAutomaton GetFSA()
{
MooreAutomaton moore = new MooreAutomaton(new MooreState[] {
// Normal
new MooreState {
Table = new TableGenerator {
EmptyTransition = (int) States.Normal,
HashTransitions = new Hashtable {
{ Input.MouseEnter, States.OverObject }
},
Size = TABLE_SIZE
}.GenerateTable(),
Output = (int)Output.NormalCursor
},
// over object
new MooreState {
Table = new TableGenerator {
EmptyTransition = (int) States.OverObject,
HashTransitions=new Hashtable {
{ Input.MouseLeave, States.Normal },
{ Input.MouseDown, States.Moving }
}
}.GenerateTable(),
Output = (int) Output.TakeCursor
}
,
// moving
new MooreState {
Table = new TableGenerator {
EmptyTransition = (int) States.Moving,
HashTransitions = new Hashtable {
{ Input.MouseUp, States.OverObject }
}
}.GenerateTable(),
Output = (int) Output.MoveCursor
}
}
);
return moore;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
My name is Jacek. Currently, I am a Java/kotlin developer. I like C# and Monthy Python's sense of humour.