Ejemplo n.º 1
0
        /// <summary>
        /// Asettelee alakomponentin oikealle paikalle
        /// </summary>
        /// <param name="control"></param>
        /// <param name="constraint"></param>
        private void DownConstraint(Control control, BorderLayoutConstraint constraint)
        {
            Vector2 position = new Vector2();

            position.Y = container.Size.Height - control.Size.Height;

            if (slots.ContainsKey(left.Direction))
            {
                Control leftArea = slots[left.Direction];
                position.X = leftArea.Size.Width;
            }

            ControlSize size = new ControlSize(container.Size.Width - (int)position.X, control.Size.Height);

            if (slots.ContainsKey(right.Direction))
            {
                Control     rightArea = slots[right.Direction];
                ControlSize temp      = new ControlSize(size.Width - rightArea.Size.Width, size.Height);
                size = temp;
            }

            control.Size = size;
            control.Position.Relative = position;

            slots[constraint.Direction] = control;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Lisää kontrollin constrainien perusteella oikealle paikalle
        /// Asettelee komponentit uudelleen jos tulevat päällekkäin
        /// </summary>
        /// <param name="controlManager">Mihin controlmanageriin lisätään</param>
        /// <param name="controlToAdd">Mikä kontrolli lisätään</param>
        /// <param name="constraints">Mihin paikkaan layoutissa (Center, Left, Right, Up, Down)</param>
        public override void Add(ControlManager controlManager, Control controlToAdd, ILayoutConstraints constraints)
        {
            if (constraints != null && constraints is BorderLayoutConstraint)
            {
                BorderLayoutConstraint constraint = (constraints as BorderLayoutConstraint);
                invokeList[constraint.Direction].Invoke(controlToAdd, constraint);
                controlManager.AddControl(controlToAdd);

                ReAlignCenter();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Asettelee vasemman komponentin vasemmalle
        /// </summary>
        /// <param name="control"></param>
        /// <param name="constraint"></param>
        private void LeftConstraint(Control control, BorderLayoutConstraint constraint)
        {
            Vector2 position = new Vector2();

            if (slots.ContainsKey(up.Direction))
            {
                Control upArea = slots[up.Direction];
                position.Y = upArea.Size.Height;
            }
            ControlSize size = new ControlSize(control.Size.Width, container.Size.Height - (int)position.Y);

            if (slots.ContainsKey(down.Direction))
            {
                Control downArea = slots[down.Direction];
                size = new ControlSize(size.Width, container.Size.Width - ((int)position.Y - downArea.Size.Height));
            }
            control.Position.Relative = position;
            control.Size = size;

            slots[constraint.Direction] = control;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Asettaa keskikomponentin keskelle
        /// </summary>
        /// <param name="c"></param>
        /// <param name="b"></param>
        private void CenterConstraint(Control c, BorderLayoutConstraint b)
        {
            Vector2 position = new Vector2();

            if (slots.ContainsKey(left.Direction))
            {
                Control leftArea = slots[left.Direction];

                position.X = leftArea.Position.Relative.X + leftArea.Size.Width;
            }

            if (slots.ContainsKey(up.Direction))
            {
                Control upArea = slots[up.Direction];
                position.Y = (int)upArea.Position.Relative.Y + upArea.Size.Height;
            }

            ControlSize size = new ControlSize(container.Size.Width - (int)position.X, container.Size.Height - (int)position.Y, SizeType.Fixed);

            if (slots.ContainsKey(right.Direction))
            {
                Control     rightArea = slots[right.Direction];
                ControlSize temp      = new ControlSize(size.Width - rightArea.Size.Width, size.Height, SizeType.Fixed);
                size = temp;
            }

            if (slots.ContainsKey(down.Direction))
            {
                Control     downArea = slots[down.Direction];
                ControlSize temp     = new ControlSize(size.Width, size.Height - downArea.Size.Height, SizeType.Fixed);
                size = temp;
            }
            c.Position.Relative = position;
            c.Size = size;

            slots[b.Direction] = c;
        }
Ejemplo n.º 5
0
 public void RemoveComponent(BorderLayoutConstraint constraint)
 {
     slots.Remove(constraint.Direction);
 }