Beispiel #1
0
 public void OnMouseEvent(MouseEvent e)
 {
     GameScreen screen = GameApp.GetGurrentScreen();
     if (screen != null)
     {
         screen.GetInteractionArea().PushMouseEvent(e);
     }
 }
Beispiel #2
0
        public void PushMouseEvent(MouseEvent evt)
        {
            System.Drawing.Point p = new System.Drawing.Point();
            p.X = evt.MouseX;
            p.Y = evt.MouseY;

            if (evt.Type == EventType.Click)
            {
                for (int i = entities.Count - 1; i >= 0; i--)
                {
                    InteractionComponent entity = entities[i];

                    if (entity.IsInfinet || entities[i].IsPointInside(p))
                    {
                        entity.Click();
                        break;
                    }
                }

            }
            else if (evt.Type == EventType.Down)
            {

                for (int i = entities.Count - 1; i >= 0; i--)
                {
                    InteractionComponent entity = entities[i];

                    if (entities[i].IsPointInside(p) && entity.Dragable)
                    {
                        dragedComponent = entity;
                        relativeX = p.X - entity.X;
                        relativeY = p.Y - entity.Y;
                        break;
                    }
                }

            }
            else if (evt.Type == EventType.Move)
            {
                if (dragedComponent != null)
                {
                    dragedComponent.X = p.X - relativeX;
                    dragedComponent.Y = p.Y - relativeY;

                    dragedComponent.Drag();
                }

            }

            else if (evt.Type == EventType.Up)
            {
                dragedComponent = null;
            }
        }
        public void OnMouseEvent(MouseEvent e)
        {
            if (e.Type == EventType.Click)
            {
                GameScreen currentScreen = GameApp.GetGurrentScreen();

                ScreenEntity entity = null;

                if (type == ObjectType.Sprite)
                {
                    Sprite s;
                    if (obj != null)
                        s = (Sprite)obj;
                    else s = new Sprite();
                    entity = s;

                    s.InstanceName = "sprite";

                    currentScreen.AddSprite(s);
                    s.ShowPropsPanel();

                }
                else
                {
                    Text t;
                    if (obj != null)
                        t = (Text)obj;
                    else t = new Text();
                    entity = t;

                    t.InstanceName = "text";
                    currentScreen.AddText(t);
                    t.ShowPropPanel();
                }

                entity.X = e.MouseX - entity.ClipWidth / 2;
                entity.Y = e.MouseY - entity.ClipHeight / 2;

                FocusHandler.SetFocusComponent(entity.GetFocusComponent());
                ToolManager.SetCurrentTool(new InteractionTool());
            }
        }
Beispiel #4
0
 public static void PushMouseEvent(MouseEvent e)
 {
     if (currentTool != null)
         currentTool.OnMouseEvent(e);
 }
Beispiel #5
0
        void pbDraw_MouseUp(object sender, MouseEventArgs e)
        {
            MouseEvent evt = new MouseEvent();
            evt.Type = EventType.Up;
            evt.MouseX = e.X;
            evt.MouseY = e.Y;

            ToolManager.PushMouseEvent(evt);
        }