コード例 #1
0
 /**
  * Sets the object's parent. Makes sure there are no null.
  * To unset the parent, use the RemoveParent() method.
  */
 public virtual void SetParent(MyOnScreenObject ParentObject)
 {
     if (ParentObject != null)
     {
         this.ParentObject = ParentObject;
     }
 }
コード例 #2
0
 public void AddChildAtLocation(MyOnScreenObject ChildObject, int x, int y)
 {
     if (ChildObject != null)
     {
         ChildObject.SetPosition(x, y);
         AddChild(ChildObject);
     }
 }
コード例 #3
0
 /**
  * Adds the referenced object to the list of child objects while
  * also setting its parent object reference to this object
  */
 public virtual void AddChild(MyOnScreenObject ChildObject)
 {
     if (ChildObject != null)
     {
         ChildObjects.Add(ChildObject);
         ChildObject.SetParent(this);
     }
 }
コード例 #4
0
 /**
  * Removes the referenced child from the list of child objects and
  * sets its parent reference to null
  */
 public virtual void RemoveChild(MyOnScreenObject ChildObject)
 {
     if (ChildObject != null)
     {
         ChildObjects.Remove(ChildObject);
         ChildObject.RemoveParent();
     }
 }
コード例 #5
0
        public MyOnScreenObject(MyOnScreenObject ParentObject, int x, int y, bool isVisible)
        {
            this.SetParent(ParentObject);
            this.x         = x;
            this.y         = y;
            this.isVisible = isVisible;

            if (ParentObject != null)
            {
                ParentObject.AddChild(this);
            }
        }
コード例 #6
0
        public override void RemoveChild(MyOnScreenObject Item)
        {
            base.RemoveChild(Item);

            if (Item == SelectedItem)
            {
                SetInitialSelectedItem(ChildObjects[0]);
                UpdateScrollbarPosition();
            }

            Items.Remove(Item);

            UpdateItemPositions();
        }
コード例 #7
0
        public override void AddChild(MyOnScreenObject Item)
        {
            base.AddChild(Item);

            if (SelectedItem == null)
            {
                SetInitialSelectedItem(Item);
                UpdateScrollbarPosition();
            }

            Items.Add(Item);

            UpdateItemPositions();
        }
コード例 #8
0
 private int ComputeItemHorizontalPosition(MyOnScreenObject Item)
 {
     if (horizontalAlignment == Constants.HORIZONTAL_ALIGN_RIGHT)
     {
         return(GetWidth() - Scrollbar.GetWidth() - padding - Item.GetWidth());
     }
     else if (horizontalAlignment == Constants.HORIZONTAL_ALIGN_CENTER)
     {
         return((GetWidth() - Scrollbar.GetWidth() - Item.GetWidth()) / 2);
     }
     else
     {
         return(padding);
     }
 }
コード例 #9
0
        public MyOnScreenObject SelectPreviousItem()
        {
            if (SelectedItem != null)
            {
                selectedItemIndex = Items.IndexOf(SelectedItem); // if it doesn't work, use this: int index = myList.FindIndex(a => a.Prop == oProp);
                if (selectedItemIndex > 0)
                {
                    selectedItemIndex--;
                    SelectedItem = Items[selectedItemIndex];
                    UpdateItemPositions();
                    UpdateScrollbarPosition();
                }
            }

            return(SelectedItem);
        }
コード例 #10
0
        public MyOnScreenObject SelectNextItem()
        {
            if (SelectedItem != null)
            {
                selectedItemIndex = Items.IndexOf(SelectedItem); // if it doesn't work, use this: int index = myList.FindIndex(a => a.Prop == oProp);
                if (selectedItemIndex >= 0 && selectedItemIndex < Items.Count() - 1)
                {
                    selectedItemIndex++;
                    SelectedItem = Items[selectedItemIndex];
                    UpdateItemPositions();
                    UpdateScrollbarPosition();
                }
            }

            return(SelectedItem);
        }
コード例 #11
0
 private MySprite[] ResolveFont()
 {
     if (Font == null)
     {
         MyOnScreenObject TopLevelParent = GetTopLevelParent();
         if (TopLevelParent is MyPage)
         {
             return(((MyPage)TopLevelParent).GetApplication().GetCanvas().GetDefaultFont());
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(Font);
     }
 }
コード例 #12
0
 /**
  * Removes the object's parent
  */
 public void RemoveParent()
 {
     this.ParentObject = null;
 }
コード例 #13
0
 public MyScrollbar(MyOnScreenObject ParentObject)
     : base(ParentObject, 0, 0, true)
 {
 }
コード例 #14
0
 private void SetInitialSelectedItem(MyOnScreenObject Item)
 {
     SelectedItem      = Item;
     selectedItemIndex = 0;
     startPosY         = padding;
 }