Esempio n. 1
0
        public override void Paint(IComponentPainter painter)
        {
            module.Presentation.Paint(painter);

            ModuleInstance instance   = painter.Instance as ModuleInstance;
            int            glassColor = 0;

            switch (instance.PokeState)
            {
            case ModuleInstance.FirstDepress:
                glassColor = 0xFF9999;
                break;

            case ModuleInstance.Touched:
                glassColor = 0;
                break;

            case ModuleInstance.SecondDepress:
                glassColor = 0xA00000;
                break;

            default:
                glassColor = 0xBBBBBB;
                break;
            }
            Bounds bds    = this.OffsetBounds;
            int    glassX = bds.X + bds.Width / 2 - 4;
            int    glassY = bds.Y + bds.Height / 2 - 4;

            painter.Color       = glassColor;
            painter.StrokeWidth = 4;
            painter.StrokeCircle(glassX, glassY, 14);
            painter.StrokeLine(glassX + 10, glassY + 10, glassX + 18, glassY + 18);
        }
Esempio n. 2
0
        public void ProcessPokeEvent(PokeEventArgs args)
        {
            switch (args.Type)
            {
            case PokeEventType.PokeStart:
                args.StateUpdate = (IInstanceState state) => {
                    ModuleInstance instance = state.Instance as ModuleInstance;
                    int            oldState = instance.PokeState;
                    int            newState = oldState;
                    if (IsInGlass(args))
                    {
                        if (oldState == ModuleInstance.Untouched)
                        {
                            newState = ModuleInstance.FirstDepress;
                        }
                        else if (oldState == ModuleInstance.Touched)
                        {
                            newState = ModuleInstance.SecondDepress;
                        }
                    }
                    else
                    {
                        newState = ModuleInstance.Untouched;
                        args.RejectPoke();
                    }
                    if (newState != oldState)
                    {
                        instance.PokeState = newState;
                        args.Repaint();
                    }
                };
                break;

            case PokeEventType.PokeEnd:
                args.StateUpdate = (IInstanceState state) => {
                    ModuleInstance instance = state.Instance as ModuleInstance;
                    int            oldState = instance.PokeState;
                    int            newState = oldState;
                    if (IsInGlass(args))
                    {
                        if (oldState == ModuleInstance.FirstDepress)
                        {
                            newState = ModuleInstance.Touched;
                        }
                        else if (oldState == ModuleInstance.SecondDepress)
                        {
                            newState = ModuleInstance.Untouched;
                            args.RequestView(module, instance.SimulationState);
                        }
                    }
                    else
                    {
                        if (oldState == ModuleInstance.FirstDepress)
                        {
                            newState = ModuleInstance.Untouched;
                        }
                        else if (oldState == ModuleInstance.SecondDepress)
                        {
                            newState = ModuleInstance.Touched;
                        }
                    }
                    if (newState != oldState)
                    {
                        instance.PokeState = newState;
                        args.Repaint();
                    }
                };
                break;

            case PokeEventType.PokeCancel:
                args.StateUpdate = (IInstanceState state) => {
                    ModuleInstance instance = state.Instance as ModuleInstance;
                    int            oldState = instance.PokeState;
                    int            newState = oldState;
                    if (oldState == ModuleInstance.FirstDepress)
                    {
                        newState = ModuleInstance.Untouched;
                    }
                    else if (oldState == ModuleInstance.SecondDepress)
                    {
                        newState = ModuleInstance.Touched;
                    }
                    if (newState != oldState)
                    {
                        instance.PokeState = newState;
                        args.Repaint();
                    }
                };
                break;
            }
        }