Exemple #1
0
        /// <summary>
        /// Snap the provided ToolForm to the "nearest" Toolform in the list
        /// </summary>
        /// <param name="formToSnap">Another ToolForm</param>
        public void SnapToNearest(ToolForm formToSnap)
        {
            // NOTE: merely finds the "other" form
            // TODO: when more than 2 toolforms possible, this needs to find the "nearest"
            var destForm = _formList.FirstOrDefault(x => x != formToSnap);

            if (destForm == null)
            {
                return;
            }

            // snap to top/bottom as appropriate
            if (destForm.Top > formToSnap.Bottom - MARGIN)
            {
                // snapping form ABOVE other form
                formToSnap.Top = destForm.Top - formToSnap.Height - MARGIN;
            }
            else
            {
                // snapping form BELOW or OVERLAP other form
                if (destForm.Bottom + MARGIN < formToSnap.Top ||
                    formToSnap.Top < destForm.Bottom + MARGIN)
                {
                    formToSnap.Top = destForm.Bottom + MARGIN;
                }
            }

            // snap to left/right edge as appropriate
            if (destForm.Left < formToSnap.Left)
            {
                // snapping form to the RIGHT or OVERLAP other form
                formToSnap.Left = destForm.Right - formToSnap.Width;
            }
            else
            {
                // snapping form to the LEFT of other form
                formToSnap.Left = destForm.Left;
            }
        }
Exemple #2
0
 /// <summary>
 /// Add a new ToolForm to the manager
 /// </summary>
 /// <param name="client">A ToolForm</param>
 public void Add(ToolForm client)
 {
     _formList.Add(client);
 }