コード例 #1
0
 private static void HandleIsMouseOver(GuiElement element, MouseState newState)
 {
     if (!element.Bounds.Contains(newState.X, newState.Y))
     {
         return;
     }
     HandleIsMouseOverForAllChildren(element, newState);
 }
コード例 #2
0
        private void HandleMouseMoved(GuiElement element, MouseState newState, MouseMovedEventHandler handler)
        {
            if (!element.Bounds.Contains(newState.X, newState.Y))
            {
                return;
            }

            HandleMouseMovedForChildren(element, newState, handler);
        }
コード例 #3
0
 private void HandleMouseMovedForChildren(GuiElement element, MouseState newState, MouseMovedEventHandler handler)
 {
     foreach (var childElement in element.Children)
     {
         if (childElement.Bounds.Contains(newState.X, newState.Y) && childElement.IsMouseOver)
         {
             childElement.OnMouseMove(handler);
             if (handler.Handled)
             {
                 return;
             }
             HandleMouseMovedForChildren(childElement, newState, handler);
         }
     }
 }
コード例 #4
0
 private static void HandleIsMouseOverForAllChildren(GuiElement parent, MouseState newState)
 {
     foreach (var childElement in parent.Children)
     {
         if (childElement.Bounds.Contains(newState.X, newState.Y))
         {
             if (!childElement.IsMouseOver)
             {
                 childElement.OnMouseOver(new EventHandler());
                 childElement.IsMouseOver = true;
             }
             HandleIsMouseOverForAllChildren(childElement, newState);
         }
         else if (childElement.IsMouseOver)
         {
             childElement.IsMouseOver = false;
             childElement.OnMouseLeft(new EventHandler());
         }
     }
 }
コード例 #5
0
ファイル: Grid.cs プロジェクト: trommlbomml/Game2DFramework
 private void AddChild(int column, int row, GuiElement element)
 {
     _childElementsByLinearTableIndex.Add(new Tuple <int, int>(column, row), element);
     Children.Add(element);
 }
コード例 #6
0
 public void AddChild(GuiElement child)
 {
     Children.Add(child);
 }
コード例 #7
0
 private static GuiElement InvokeEventForChildren <THandler>(MouseState state, GuiElement parent, THandler handler, Action <GuiElement, THandler> action) where THandler : EventHandler
 {
     foreach (var childElement in parent.Children)
     {
         if (childElement.Bounds.Contains(state.X, state.Y))
         {
             action(childElement, handler);
             if (handler.Handled)
             {
                 return(childElement);
             }
             return(InvokeEventForChildren(state, childElement, handler, action));
         }
     }
     return(null);
 }
コード例 #8
0
 public void AddElement(GuiElement element)
 {
     _elements.Add(element);
     element.Arrange(Game.GetScreenRectangle());
 }