Ejemplo n.º 1
0
 public void Add(FluidControl c)
 {
     if (!panel.Controls.Contains(c))
     {
         panel.Controls.Add(c);
     }
 }
Ejemplo n.º 2
0
 public void Insert(int index, FluidControl c)
 {
     if (!panel.Controls.Contains(c))
     {
         panel.Controls.Insert(index, c);
     }
 }
Ejemplo n.º 3
0
        private static void Adjust(FluidControl c, Size oldContainerSize, Size newContainerSize, SizeF scaleFactor)
        {
            Rectangle bounds = c.Bounds;
            int left = bounds.Left;
            int right = bounds.Right;
            int top = bounds.Top;
            int bottom = bounds.Bottom;

            AnchorStyles a = c.Anchor;
            if ((a & AnchorStyles.Right) != 0)
            {
                int dw = newContainerSize.Width - oldContainerSize.Width;
                right += dw;
                if ((a & AnchorStyles.Left) == 0)
                {
                    left += dw;
                }
            }

            if ((a & AnchorStyles.Bottom) != 0)
            {
                int dh = newContainerSize.Height - oldContainerSize.Height;
                bottom += dh;
                if ((a & AnchorStyles.Top) == 0)
                {
                    top += dh;
                }
            }
            Rectangle b = new Rectangle(left, top, right - left, bottom - top);
            if (c.Bounds.Size != b.Size)
            {
                c.Scale(scaleFactor);
            }
            c.Bounds = b;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Leaves the control if focused and sets the focus to the next parent control that is Selectable<see cref="Selectable"/>.
        /// </summary>
        public void OnLostFocus()
        {
            if (!IsAttached)
            {
                return;
            }
            IHost host = Container.Host;

            if (host.FocusedControl == this)
            {
                FluidControl parent = Parent;
                while (parent != null)
                {
                    if (parent.Selectable)
                    {
                        host.FocusedControl = parent;
                        return;
                    }
                    parent = parent.Parent;
                }
                host.FocusedControl = null;
                if (LostFocus != null)
                {
                    LostFocus(this, EventArgs.Empty);
                }
            }
        }
Ejemplo n.º 5
0
        private void PaintControlDoubleBuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
        {
            Bitmap buffer;

            if (imageBuffer.Contains(control))
            {
                buffer = imageBuffer[control] as Bitmap;
            }
            else
            {
                buffer = new Bitmap(bounds.Width, bounds.Height);
                imageBuffer.Add(control, buffer);
                using (Graphics bg = Graphics.FromImage(buffer))
                {
                    this.transparentBrush.Color = transparentColor;
                    bg.FillRectangle(transparentBrush, 0, 0, buffer.Width, buffer.Height);
                    Rectangle paintRect = control.ClientRectangle;
                    //bg.Clear(transparentColor);

                    FluidPaintEventArgs e = paintEventArgs;
                    e.Graphics      = bg;
                    e.ControlBounds = paintRect;
                    e.Region        = bg.Clip;
                    e.ScaleFactor   = pe.ScaleFactor;
                    control.OnPaint(e);
                }
            }
            ia.SetColorKey(transparentColor, transparentColor);
            pe.Graphics.DrawImage(buffer, bounds, 0, 0, bounds.Width, bounds.Height, GraphicsUnit.Pixel, ia);
        }
Ejemplo n.º 6
0
 private PointEventArgs TranslatePoint(FluidControl c, PointEventArgs p)
 {
     p.X -= c.Bounds.X;
     p.Y -= c.Bounds.Y;
     //PointEventArgs e = new PointEventArgs(p.Gesture, p.X - c.Bounds.X, p.Y - c.Bounds.Y);
     return(p);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Ensures that the selected control is removed (OnLeave) if it is a descendant of this control.
 /// </summary>
 /// <returns>True, if the focused control was nested in this control, otherwise false.</returns>
 public bool LeaveNestedFocusedControl()
 {
     if (IsAttached)
     {
         IContainer container = this as IContainer;
         if (container != null)
         {
             if (Container == null || Container.Host == null)
             {
                 return(false);
             }
             FluidControl selected = IsAttached ? Container.Host.FocusedControl : null;
             if (selected != null)
             {
                 if (container != null && selected.IsDescendantOf(container))
                 {
                     if (IsAttached)
                     {
                         Container.Host.FocusedControl = this.Selectable ? this : null;
                     }
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 8
0
 public CommandEventArgs(string command, FluidControl control, object data)
     : base()
 {
     this.Command        = command;
     this.OriginalSource = control;
     this.Data           = data;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Layouts a control when it has changed it's size depending on it's anchor style.
        /// </summary>
        /// <param name="c"></param>
        /// <param name="oldContainerSize"></param>
        /// <param name="newContainerSize"></param>
        /// <param name="scaleFactor"></param>
        public static void AdjustSize(FluidControl c, Size oldContainerSize, Size newContainerSize, SizeF scaleFactor)
        {
            Rectangle bounds = c.Bounds;
            int left = bounds.Left;
            int right = bounds.Right;
            int top = bounds.Top;
            int bottom = bounds.Bottom;

            AnchorStyles a = c.Anchor;
            if ((a & AnchorStyles.Right) != 0 && (a & AnchorStyles.Left) == 0)
            {
                int dw = newContainerSize.Width - oldContainerSize.Width;
                right -= dw;
                left -= dw;
            }

            if ((a & AnchorStyles.Bottom) != 0 && (a & AnchorStyles.Top) == 0)
            {
                int dh = newContainerSize.Height - oldContainerSize.Height;
                bottom -= dh;
                top -= dh;
            }
            Rectangle b = new Rectangle(left, top, right - left, bottom - top);
            c.bounds = b;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Layouts a control when it has changed it's size depending on it's anchor style.
        /// </summary>
        /// <param name="c"></param>
        /// <param name="oldContainerSize"></param>
        /// <param name="newContainerSize"></param>
        /// <param name="scaleFactor"></param>
        public static void AdjustSize(FluidControl c, Size oldContainerSize, Size newContainerSize, SizeF scaleFactor)
        {
            Rectangle bounds = c.Bounds;
            int       left   = bounds.Left;
            int       right  = bounds.Right;
            int       top    = bounds.Top;
            int       bottom = bounds.Bottom;

            AnchorStyles a = c.Anchor;

            if ((a & AnchorStyles.Right) != 0 && (a & AnchorStyles.Left) == 0)
            {
                int dw = newContainerSize.Width - oldContainerSize.Width;
                right -= dw;
                left  -= dw;
            }

            if ((a & AnchorStyles.Bottom) != 0 && (a & AnchorStyles.Top) == 0)
            {
                int dh = newContainerSize.Height - oldContainerSize.Height;
                bottom -= dh;
                top    -= dh;
            }
            Rectangle b = new Rectangle(left, top, right - left, bottom - top);

            c.bounds = b;
        }
Ejemplo n.º 11
0
 public CommandEventArgs(string command, FluidControl control, object data)
     : base()
 {
     this.Command = command;
     this.OriginalSource = control;
     this.Data = data;
 }
Ejemplo n.º 12
0
 public override void OnUp(PointEventArgs p)
 {
     if (downControl != null)
     {
         downControl.OnUp(TranslatePoint(downControl, p));
     }
     downControl = null;
 }
Ejemplo n.º 13
0
        public void Hide(FluidControl control)
        {
            Rectangle bounds = control.Bounds;

            panel.Controls.Remove(control);
            panel.Invalidate(bounds);
            control.Visible = false;
        }
Ejemplo n.º 14
0
 void animation_Completed(object sender, EventArgs e)
 {
     transitionControl.Bounds = ClientRectangle;
     SelectedControl          = transitionControl;
     transitionControl        = null;
     currentTransition        = Transition.None;
     dBufferRequired          = false;
     OnTransitionCompleted(sender as Animation);
 }
Ejemplo n.º 15
0
 public void ShowMaximized(FluidControl control)
 {
     panel.BeginInit();
     panel.Controls.Add(control);
     control.Bounds = panel.ClientRectangle;
     panel.EndInit();
     control.Anchor = FluidControl.AnchorAll;
     panel.Invalidate(control.Bounds);
 }
Ejemplo n.º 16
0
        protected void PaintControlUnbuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
        {
            FluidPaintEventArgs e = paintEventArgs;

            e.Graphics      = pe.Graphics;
            e.ControlBounds = bounds;
            e.Region        = pe.Region;
            e.ScaleFactor   = pe.ScaleFactor;
            control.OnPaint(e);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Ensure that the specified control is visible, and make it become visible if not.
        /// </summary>
        /// <param name="c">The control that needs to be visible.</param>
        /// <returns>True, if the control was already visible, otherwise false.</returns>
        public bool EnsureVisible(FluidControl c)
        {
            bool      result = true;
            Rectangle bounds = c.Bounds;

            bounds.Y -= TopOffset;
            if (!Bounds.Contains(bounds))
            {
                EnsureVisible(bounds);
            }
            return(result);
        }
Ejemplo n.º 18
0
        private void PaintControl(FluidPaintEventArgs pe, FluidControl c)
        {
            Rectangle controlBounds = pe.ControlBounds;
            Region    clip          = pe.Region;
            Rectangle bounds        = c.Bounds;

            bounds.Offset(controlBounds.X, controlBounds.Y);
            if (clip.IsVisible(bounds))
            {
                PaintControlUnbuffered(pe, c, bounds);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Removes the focus of the selected control, if this control is a parent of the selected control.
        /// </summary>
        private void LeaveDescendant()
        {
            FluidControl selected = Container.Host.FocusedControl;

            if (selected != null)
            {
                if (selected.IsDescendantOf(this))
                {
                    Container.Host.FocusedControl = this;
                }
            }
        }
Ejemplo n.º 20
0
        private void PaintControlUnbuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
        {
            //bounds.Offset(Left, Top);
            //Region clp = pe.IntersectClip(bounds);
            FluidPaintEventArgs e = paintEventArgs2;

            e.Graphics      = pe.Graphics;
            e.ControlBounds = bounds;
            e.Region        = pe.Region;
            e.ScaleFactor   = pe.ScaleFactor;
            control.OnPaint(e);
            //pe.ResetClip(clp);
        }
Ejemplo n.º 21
0
        public override void PerformClick()
        {
            base.PerformClick();
            FluidControl control = selectedControl;

            if (control != null)
            {
                if (control.Selectable)
                {
                    Host.FocusedControl = control;
                }
            }
        }
Ejemplo n.º 22
0
        private bool isAncestorDoubleBuffered()
        {
            FluidControl parent = this.Parent;

            while (parent != null)
            {
                if (parent.IsDoubleBuffered)
                {
                    return(true);
                }
                parent = parent.Parent;
            }
            return(false);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Gets whether this control is a descendant of the specified container.
        /// </summary>
        /// <param name="container">The container which might be an ancestor.</param>
        /// <returns>True, if this control is a descendant of the container (or the container is an ancestor of the control), otherwhise false.</returns>
        public bool IsDescendantOf(IContainer container)
        {
            FluidControl parent = Parent;

            while (parent != null)
            {
                if (parent == container)
                {
                    return(true);
                }
                parent = parent.Parent;
            }
            return(false);
        }
Ejemplo n.º 24
0
        protected virtual void OnSelectedIndexChanging(ChangedEventArgs <int> e)
        {
            if (Initializing)
            {
                return;
            }
            int index = e.NewValue;

            if (e.NewValue >= 0)
            {
                FluidControl c = Pages[index].Control;
                c.Invalidate();
                c.Focus();
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Give back the focus to the control that had the focus before this panel appeared and grabbed the focus,
 /// but only if the current focused control belong to a control nested inside this panel.
 /// </summary>
 private void RestorePreviousFocusedControl()
 {
     if (LeaveNestedFocusedControl())
     {
         // check if the previous control is still focusable and alive:
         if (previousFocusedControl != null && (!previousFocusedControl.Enabled || !previousFocusedControl.IsAvailable))
         {
             previousFocusedControl = null;
         }
         if (Host != null)
         {
             Host.FocusedControl = previousFocusedControl;
         }
     }
     previousFocusedControl = null;
 }
Ejemplo n.º 26
0
        public void Paint(FluidPaintEventArgs e, FluidControl control, PaintFunc paintFunc, int alpha)
        {
            Rectangle dst = e.ControlBounds;

            //            Rectangle dst = control.Bounds;
            EnsureDBuffer(dst.Width, dst.Height);
            PaintBuffer(paintFunc, e.ScaleFactor);
            if (alpha >= 255)
            {
                e.Graphics.DrawImage(dbuffer, dst.X, dst.Y);
            }
            else
            {
                GdiExt.AlphaBlendImage(e.Graphics, dbuffer, dst.X, dst.Y, alpha, false);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Paints all  controls.
        /// The controls are painted in an optimized way:
        /// The controls are rendered from the last to the first, and after painting each control, the bounds of the control are excluded from the region, so this region is not painted twice.
        /// If a there is a transparent control, the remaining controls are painted from the first to this control, while the region is not excluded.
        /// </summary>
        /// <param name="pe">The PaintEventArgs.</param>
        protected virtual void PaintControls(FluidPaintEventArgs pe)
        {
#if true
            Region region = null;


            Region   clip  = pe.Region;
            Graphics g     = pe.Graphics;
            int      index = 0;


            for (int i = controls.Count - 1; i >= 0; i--)
            {
                FluidControl c = controls[i];
                if (c.Visible && c.IsTransparent)
                {
                    region = pe.Graphics.Clip;
                    index  = i + 1;
                    break;
                }
                Rectangle bounds = PaintControl(pe, c);
                if (!bounds.IsEmpty)
                {
                    clip.Exclude(bounds);
                    g.Clip = clip;
                }
            }
            for (int i = 0; i < index; i++)
            {
                FluidControl c = controls[i];
                if (c.IsTransparent)
                {
                    pe.Graphics.Clip = region;
                }
                PaintControl(pe, c);
            }
            if (region != null)
            {
                region.Dispose();
            }
#else
            foreach (FluidControl c in controls)
            {
                PaintControl(pe, c);
            }
#endif
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Leaves the focus from this control.
 /// </summary>
 public virtual void Leave()
 {
     if (Selectable && IsAttached)
     {
         FluidControl parent = Parent;
         while (parent != null)
         {
             if (parent.Selectable)
             {
                 parent.Focus();
                 return;
             }
             parent = parent.Parent;
         }
         OnLeave(Container.Host);
     }
 }
Ejemplo n.º 29
0
 public void Switch(int index, Transition transition, int duration)
 {
     alpha = 255;
     if (index != selectedIndex)
     {
         StopTransition();
         currentTransition = transition;
         dBufferRequired   = RequiresDBuffer(transition);
         transitionFunc    = GetTransitionFunc(transition);
         transitionControl = Controls[index];
         Animation animation = EnsureAnimation();
         animation.BeginValue = 0;
         animation.EndValue   = Width;
         animation.Duration   = duration;
         OnBeginTransition(index);
         animation.Start();
     }
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Gets the first control that is under the specified point.
 /// </summary>
 /// <param name="x">The x value of the point.</param>
 /// <param name="y">The y value of the point.</param>
 /// <returns>An ITouchControl, otherwise null.</returns>
 /// <remarks>
 /// The enumeration starts from the last to the first control, because the controls appear in this
 /// order in case they are overlapping.
 /// </remarks>
 public virtual FluidControl ControlFromPoint(int x, int y)
 {
     p.X = x;
     p.Y = y;
     for (int i = controls.Count - 1; i >= 0; i--)
     {
         FluidControl c = controls[i];
         if (!c.Visible)
         {
             continue;
         }
         Rectangle r = c.Bounds;
         if (r.Contains(p))
         {
             return(c);
         }
     }
     return(null);
 }
Ejemplo n.º 31
0
        protected override void PaintControls(FluidPaintEventArgs pe)
        {
            FluidControl c  = SelectedControl;
            FluidControl tc = transitionControl;

            if (tc == null && (c is PageControl))
            {
                /// build a short cut for performance issues:
                c = ((PageControl)c).Control;
            }
            if (c != null)
            {
                PaintControl(pe, c);
            }

            if (tc != null)
            {
                PaintControl(pe, tc);
            }
        }
Ejemplo n.º 32
0
        public override void OnDown(PointEventArgs p)
        {
            base.OnDown(p);
            FluidControl control = ControlFromPoint(p.X, p.Y);

            downControl = control;
            if (control != null)
            {
                PointEventArgs p2 = TranslatePoint(control, p);
                control.OnDown(p2);
            }
            if (control != null && control.Selectable)
            {
                selectedControl = control;
            }
            else if (control == null)
            {
                selectedControl = null;
            }
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Gets the first control that is under the specified point.
        /// </summary>
        /// <param name="x">The x value of the point.</param>
        /// <param name="y">The y value of the point.</param>
        /// <returns>An ITouchControl, otherwise null.</returns>
        /// <remarks>
        /// The enumeration starts from the last to the first control, because the controls appear in this
        /// order in case they are overlapping.
        /// </remarks>
        public FluidControl ControlFromPoint(int x, int y)
        {
            Point p = checkPoint;

            p.X = x;
            p.Y = y + TopOffset;
            for (int i = controls.Count - 1; i >= 0; i--)
            {
                FluidControl c = controls[i];
                if (!c.Visible)
                {
                    continue;
                }
                Rectangle r = c.Bounds;
                if (r.Contains(p))
                {
                    return(c);
                }
            }
            return(null);
        }
Ejemplo n.º 34
0
 protected override void BeginMoving()
 {
     base.BeginMoving();
     selectedControl = null;
 }
Ejemplo n.º 35
0
 public override void OnUp(PointEventArgs p)
 {
     if (downControl != null) downControl.OnUp(TranslatePoint(downControl, p));
     downControl = null;
 }
Ejemplo n.º 36
0
 public override void OnDown(PointEventArgs p)
 {
     base.OnDown(p);
     FluidControl control = ControlFromPoint(p.X, p.Y);
     downControl = control;
     if (control != null)
     {
         PointEventArgs p2 = TranslatePoint(control, p);
         control.OnDown(p2);
     }
     if (control != null && control.Selectable)
     {
         selectedControl = control;
     }
     else if (control == null)
     {
         selectedControl = null;
     }
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Give back the focus to the control that had the focus before this panel appeared and grabbed the focus,
 /// but only if the current focused control belong to a control nested inside this panel.
 /// </summary>
 private void RestorePreviousFocusedControl()
 {
     if (LeaveNestedFocusedControl())
     {
         // check if the previous control is still focusable and alive:
         if (previousFocusedControl != null && (!previousFocusedControl.Enabled || !previousFocusedControl.IsAvailable)) previousFocusedControl = null;
         if (Host != null) Host.FocusedControl = previousFocusedControl;
     }
     previousFocusedControl = null;
 }
Ejemplo n.º 38
0
 void animation_Completed(object sender, EventArgs e)
 {
     transitionControl.Bounds = ClientRectangle;
     SelectedControl = transitionControl;
     transitionControl = null;
     currentTransition = Transition.None;
     dBufferRequired = false;
     OnTransitionCompleted(sender as Animation);
 }
Ejemplo n.º 39
0
        public void Switch(int index, Transition transition, int duration)
        {
            StopTransition();
            if (index != selectedIndex)
            {
                alpha = 255;
                currentTransition = transition;
                dBufferRequired = RequiresDBuffer(transition);
                transitionFunc = GetTransitionFunc(transition);
                transitionControl = Controls[index];
                Animation animation = EnsureAnimation();

                animation.BeginValue = 0;
                animation.EndValue = Width;
                animation.Duration = duration;
                OnBeginTransition(index);
                animation.Start();
            }
        }
Ejemplo n.º 40
0
 private PointEventArgs TranslatePoint(FluidControl c, PointEventArgs p)
 {
     p.X -= c.Bounds.X;
     p.Y -= c.Bounds.Y;
     //PointEventArgs e = new PointEventArgs(p.Gesture, p.X - c.Bounds.X, p.Y - c.Bounds.Y);
     return p;
 }
Ejemplo n.º 41
0
 private PointEventArgs TranslatePoint(FluidControl c, PointEventArgs p)
 {
     p.X -= c.Bounds.X;
     p.Y -= c.Bounds.Y;
     return p;
 }
Ejemplo n.º 42
0
 public void Paint(FluidPaintEventArgs e, FluidControl control, PaintFunc paintFunc, int alpha)
 {
     Rectangle dst = e.ControlBounds;
     //            Rectangle dst = control.Bounds;
     EnsureDBuffer(dst.Width, dst.Height);
     PaintBuffer(paintFunc, e.ScaleFactor);
     if (alpha >= 255)
     {
         e.Graphics.DrawImage(dbuffer, dst.X, dst.Y);
     }
     else
     {
         GdiExt.AlphaBlendImage(e.Graphics, dbuffer, dst.X, dst.Y, alpha, false);
     }
 }
Ejemplo n.º 43
0
 public void Paint(FluidPaintEventArgs e, FluidControl control, PaintFunc paintFunc)
 {
     Paint(e, control, paintFunc, 255);
 }
Ejemplo n.º 44
0
 private void PaintControl(FluidPaintEventArgs pe, FluidControl c)
 {
     Rectangle controlBounds = pe.ControlBounds;
     Region clip = pe.Region;
     Rectangle bounds = c.Bounds;
     bounds.Offset(controlBounds.X, controlBounds.Y);
     if (clip.IsVisible(bounds))
     {
         PaintControlUnbuffered(pe, c, bounds);
     }
 }
Ejemplo n.º 45
0
 public ControlEventArgs(FluidControl c)
 {
     Control = c;
 }
Ejemplo n.º 46
0
        private void PaintControlDoubleBuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
        {
            Bitmap buffer;
            if (imageBuffer.Contains(control))
            {
                buffer = imageBuffer[control] as Bitmap;
            }
            else
            {
                buffer = new Bitmap(bounds.Width, bounds.Height);
                imageBuffer.Add(control, buffer);
                using (Graphics bg = Graphics.FromImage(buffer))
                {
                    this.transparentBrush.Color = transparentColor;
                    bg.FillRectangle(transparentBrush, 0, 0, buffer.Width, buffer.Height);
                    Rectangle paintRect = control.ClientRectangle;
                    //bg.Clear(transparentColor);

                    FluidPaintEventArgs e = paintEventArgs;
                    e.Graphics = bg;
                    e.ControlBounds = paintRect;
                    e.Region = bg.Clip;
                    e.ScaleFactor = pe.ScaleFactor;
                    control.OnPaint(e);
                }

            }
            ia.SetColorKey(transparentColor, transparentColor);
            pe.Graphics.DrawImage(buffer, bounds, 0, 0, bounds.Width, bounds.Height, GraphicsUnit.Pixel, ia);
        }
Ejemplo n.º 47
0
 private void PaintControlUnbuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
 {
     //bounds.Offset(Left, Top);
     //Region clp = pe.IntersectClip(bounds);
     FluidPaintEventArgs e = paintEventArgs2;
     e.Graphics = pe.Graphics;
     e.ControlBounds = bounds;
     e.Region = pe.Region;
     e.ScaleFactor = pe.ScaleFactor;
     control.OnPaint(e);
     //pe.ResetClip(clp);
 }
Ejemplo n.º 48
0
 protected void PaintControlUnbuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
 {
     FluidPaintEventArgs e = paintEventArgs;
     e.Graphics = pe.Graphics;
     e.ControlBounds = bounds;
     e.Region = pe.Region;
     e.ScaleFactor = pe.ScaleFactor;
     control.OnPaint(e);
 }
Ejemplo n.º 49
0
 public void ControlAdded(FluidControl control)
 {
     control.Visible = SelectedControl == control;
     control.Bounds = this.ClientRectangle;
 }
Ejemplo n.º 50
0
 public override void OnDown(PointEventArgs p)
 {
     if (!Enabled) return;
     base.OnDown(p);
     FluidControl control = ControlFromPoint(p.X, p.Y);
     if (control != null && !control.Active) control = null;
     downControl = control;
     selectedControl = control;
     if (control != null)
     {
         PointEventArgs pointEventArgs = TranslatePoint(control, p);
         if (control.Active) control.OnDown(pointEventArgs);
     }
 }
Ejemplo n.º 51
0
 protected override Rectangle PaintControl(FluidPaintEventArgs pe, FluidControl c)
 {
     Rectangle controlBounds = pe.ControlBounds;
     Region clip = pe.Region;
     Rectangle bounds = c.Bounds;
     bounds.Offset(controlBounds.X, controlBounds.Y);
     if (clip.IsVisible(bounds))
     {
         PaintControlUnbuffered(pe, c, bounds);
     }
     return bounds;
 }
Ejemplo n.º 52
0
 /// <summary>
 /// Ensure that the specified control is visible, and make it become visible if not.
 /// </summary>
 /// <param name="c">The control that needs to be visible.</param>
 /// <returns>True, if the control was already visible, otherwise false.</returns>
 public bool EnsureVisible(FluidControl c)
 {
     bool result = true;
     Rectangle bounds = c.Bounds;
     bounds.Y -= TopOffset;
     if (!Bounds.Contains(bounds))
     {
         EnsureVisible(bounds);
     }
     return result;
 }
Ejemplo n.º 53
0
        /// <summary>
        /// Paints the control. If the control was painted, the bounds of the rectangle in the canvas are returned, otherwise Rectangle.Empty is returned.
        /// </summary>
        /// <param name="pe">The PaintEventArgs</param>
        /// <param name="control">The control</param>
        /// <returns>If the control was painted, the bounds of the rectangle in the canvas are returned, otherwise Rectangle.Empty is returned.</returns>
        protected virtual Rectangle PaintControl(FluidPaintEventArgs pe, FluidControl control)
        {
            if (!control.Visible) return Rectangle.Empty;
            Rectangle bounds = control.Bounds;
            if (bounds.Width <= 0 || bounds.Height <= 0) return Rectangle.Empty;

            Rectangle controlBounds = pe.ControlBounds;
            Region clip = pe.Region;
            bounds.Offset(controlBounds.X, controlBounds.Y);
            if (clip.IsVisible(bounds))
            {
                PaintControlUnbuffered(pe, control, bounds);
                return bounds;
            }
            return Rectangle.Empty;
        }
Ejemplo n.º 54
0
        /// <summary>
        /// Opens the panel with the specified transition.
        /// </summary>
        /// <param name="transition">The transition to perform while the panel is shown.</param>
        public virtual void Show(ShowTransition transition)
        {
            previousFocusedControl = Host != null ? Host.FocusedControl : null;
            showTransition = transition;
            FluidTextBox.InputPanel.Enabled = false;
            Visible = false;
            FluidHost host = FluidHost.Instance;
            Rectangle client = host.ClientBounds;
            int h = client.Height;
            int w = client.Width;

            host.Add(this);
            bool modal = false;

            Bounds = GetShowStartBounds(transition);
            Visible = true;

            switch (transition)
            {
                case ShowTransition.None:
                    Show();
                    break;

                case ShowTransition.FromBottom:
                    AnimateTop(h - Bounds.Height, Animation.DefaultDuration, modal);
                    break;

                case ShowTransition.FromTop:
                    AnimateTop(Bounds.Height, Animation.DefaultDuration, modal);
                    break;

                default:
                    throw new NotImplementedException();
            }
            Focus();
            OnShowing();
        }