示例#1
0
        private static bool SwitchControls(PanelReplacement control, bool up)
        {
            var U2 = ((PanelReplacement)control.Parent);
            var F  = ((FormulaEditor)U2.Parent);

            if (F == null)
            {
                return(false);
            }

            //get index of this item

            var index = getI(U2, control.Name);

            if ((index == 0 && up) || (index == U2.Controls.Count - 1 && up == false))
            {
                return(false);
            }

            var newindex = index;

            if (up)
            {
                newindex--;
            }
            else
            {
                newindex++;
            }

            ListExtras.Swap(ref F.formulas, index, newindex);
            U2.SwitchControlLocations(index, newindex);
            return(true);
        }
示例#2
0
        /// <summary>
        /// Switches the control locations.
        /// </summary>
        /// <param name="indexone">The indexone.</param>
        /// <param name="indextwo">The indextwo.</param>
        public void SwitchControlLocations(int indexone, int indextwo)
        {
            var one = Controls[indexone];
            var two = Controls[indextwo];

            ListExtras.Swap(ref ControlStack, indexone, indextwo);

            //switch the control locs
            var x = one.Location.X;
            var y = one.Location.Y;

            one.Location = new Point(two.Location.X, two.Location.Y);
            two.Location = new Point(x, y);

            //switch the item locs
            SwapControls(one, two);
        }