示例#1
0
 public static GUILayerItem AlignItem(GUILayerItem item, LayoutRules.Positioning xPos,
                                      LayoutRules.Positioning yPos)
 {
     item.LayoutRules.XAxisPositionRule = xPos;
     item.LayoutRules.YAxisPositionRule = yPos;
     return(item);
 }
示例#2
0
        public void AddItem(GUILayerItem item)
        {
            layoutManager.PlaceItem(item, this);

            item.Init(device);
            itemsList.Add(item);
            itemsLayout.Insert(item);
        }
示例#3
0
        public void AddItem(GUILayerItem item)
        {
            layoutManager.PlaceItem(item, this);

            item.Init(device);
            itemsList.Add(item);
            itemsLayout.Insert(item);
        }
示例#4
0
        public GUILayerItem TraceCollisionPointer(Point location)
        {
            List <GUILayerItem> items = null;

            itemsLayout.CheckRadius(location.X, location.Y, ref items);
            if (items != null && items.Count > 0)
            {
                // choose last item found as it's drawn above any overlapping items in this layer
                GUILayerItem item = items[items.Count - 1];
                items.Clear();
                return(item);
            }
            return(null);
        }
示例#5
0
        public void AddItem(GUILayerItem item, EventHandler mouseEnter, EventHandler mouseLeave,
                            MouseEventHandler mouseClick)
        {
            layoutManager.PlaceItem(item, this);

            item.Init(device);
            itemsList.Add(item);
            itemsLayout.Insert(item);
            
            if (mouseEnter != null)
                item.MouseEnter += mouseEnter;
            if (mouseLeave != null)
                item.MouseLeave += mouseLeave;
            if (mouseClick != null)
            {
                item.MouseClick += mouseClick;
                item.WantMouseClicks = true;
            }
        }
示例#6
0
        public void AddItem(GUILayerItem item, EventHandler mouseEnter, EventHandler mouseLeave,
                            MouseEventHandler mouseClick)
        {
            layoutManager.PlaceItem(item, this);

            item.Init(device);
            itemsList.Add(item);
            itemsLayout.Insert(item);

            if (mouseEnter != null)
            {
                item.MouseEnter += mouseEnter;
            }
            if (mouseLeave != null)
            {
                item.MouseLeave += mouseLeave;
            }
            if (mouseClick != null)
            {
                item.MouseClick     += mouseClick;
                item.WantMouseClicks = true;
            }
        }
示例#7
0
        public void PlaceItem(GUILayerItem item, ILayer layer)
        {
            LayoutRules rules = item.LayoutRules;

            // position
            int xValue = 0;

            switch (rules.XAxisPositionRule)
            {
            case LayoutRules.Positioning.Near:
            case LayoutRules.Positioning.Absolute:
                xValue = rules.XAxisPositionValue;
                break;

            case LayoutRules.Positioning.Far:
                if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage)
                {
                    xValue = 100 - rules.XAxisPositionValue;
                }
                else
                {
                    xValue = layer.Dimensions.Width + rules.XAxisPositionValue;
                }
                break;

            case LayoutRules.Positioning.Center:
                if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage)
                {
                    xValue = 50 + rules.XAxisPositionValue;
                }
                else
                {
                    xValue = (layer.Dimensions.Width / 2) + rules.XAxisPositionValue;
                }
                break;
            }
            if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage)
            {
                xValue = (int)(100f * (xValue / (float)layer.Dimensions.Width));
            }
            xValue += layer.Position.X;

            int yValue = 0;

            switch (rules.YAxisPositionRule)
            {
            case LayoutRules.Positioning.Near:
            case LayoutRules.Positioning.Absolute:
                yValue = rules.YAxisPositionValue;
                break;

            case LayoutRules.Positioning.Far:
                if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage)
                {
                    yValue = 100 - rules.YAxisPositionValue;
                }
                else
                {
                    yValue = layer.Dimensions.Height + rules.YAxisPositionValue;
                }
                break;

            case LayoutRules.Positioning.Center:
                if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage)
                {
                    yValue = 50 + rules.YAxisPositionValue;
                }
                else
                {
                    yValue = (layer.Dimensions.Height / 2) + rules.YAxisPositionValue;
                }
                break;
            }
            if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage)
            {
                yValue = (int)(100f * (yValue / (float)layer.Dimensions.Height));
            }
            yValue += layer.Position.Y;

            item.Origin = new Point(xValue, yValue);
            item.Center = new Point(xValue + (item.Dimensions.Width / 2), yValue + (item.Dimensions.Height / 2));
        }