//=====================================================
        public static bool addToRecorded(string tabname, int rowid, int objlen)
        {
            //-------------------------------------------------
            if (massivenumbers == null)
            {
                return(false);
            }
            //-------------------------------------------------
            if (massivenumbers.Table.Length == 0)
            {
                massivenumbers.Table = tabname;
            }
            //-------------------------------------------------
            if (!massivenumbers.Table.Equals(tabname))
            {
                MessageBox.Show("Recorded Objects must belong to the same table");
                dropRecording(true);
                if (formMain != null)
                {
                    formMain.stopMassiveSetControls();
                }
                return(false);
            }
            //-------------------------------------------------
            recordStored newrecord = new recordStored();

            newrecord.RowID     = rowid;
            newrecord.ObjectLen = objlen;
            massivenumbers.addRecord(newrecord);
            return(false);
            //-------------------------------------------------
        }
Esempio n. 2
0
 //-------------------------------------------------------
 public void addRecord(recordStored rec)
 {
     //-----------------------------------------
     recordStored[] newarray = new recordStored[count + 1];
     if (count != 0)
     {
         Array.Copy(recstored, newarray, count);
     }
     newarray[count] = rec;
     recstored       = newarray;
     count++;
     //-----------------------------------------
     if (formmassive != null)
     {
         int distance = 0;
         foreach (recordStored r in newarray)
         {
             distance += r.ObjectLen;
         }
         formmassive.setAdded(count, distance);
     }
     //-----------------------------------------
 }
Esempio n. 3
0
        //=============================================================
        internal bool calculate()
        {
            //---------------------------------------------------------
            if (formmassive == null)
            {
                return(false);
            }
            //---------------------------------------------------------
            int  fromleft       = formmassive.FromLeft;
            int  toleft         = formmassive.ToLeft;
            int  fromright      = formmassive.FromRight;
            int  toright        = formmassive.ToRight;
            int  substractleft  = formmassive.SubstractLeft;
            int  substractright = formmassive.SubstractRight;
            bool evenincrements = formmassive.EvenIncrements;
            //---------------------------------------------------------
            int totaldistance = 0;

            foreach (recordStored rec in recstored)
            {
                totaldistance += rec.ObjectLen;
            }
            //---------------------------------------------------------
            float objprop;
            //---------------------------------------------
            bool first = true;
            int  leftdif = toleft - fromleft;
            int  rightdif = toright - fromright;
            int  leftincrement, rightincrement;
            //---------------------------------------------------------
            int nextfromleft  = fromleft;
            int nextfromright = fromright;
            int nexttoleft    = 0;
            int nexttoright   = 0;
            //---------------------------------------------------------
            int prevtoleft  = 0;
            int prevtoright = 0;

            //---------------------------------------------------------
            foreach (recordStored rec in recstored)
            {
                //---------------------------------------------------
                objprop        = (float)rec.ObjectLen / (float)totaldistance;
                leftincrement  = (int)(leftdif * objprop);
                rightincrement = (int)(rightdif * objprop);
                //---------------------------------------------------
                if (evenincrements)
                {
                    if ((leftincrement & 1) != 0)
                    {
                        leftincrement++;
                    }
                    if ((rightincrement & 1) != 0)
                    {
                        rightincrement++;
                    }
                }
                //---------------------------------------------------
                if (first)
                {
                    nexttoleft  = nextfromleft + leftincrement - substractleft;
                    nexttoright = nextfromright + rightincrement - substractright;
                    if (nexttoleft < 0)
                    {
                        nexttoleft = 0;
                    }
                    if (nexttoright < 0)
                    {
                        nexttoright = 0;
                    }
                    first = false;
                }
                else
                {
                    //-----------------------------------------------
                    nextfromleft  = prevtoleft;
                    nextfromright = prevtoright;
                    //-----------------------------------------------
                    if (prevtoleft != 0)
                    {
                        if (evenincrements)
                        {
                            nextfromleft += 2;
                        }
                        else
                        {
                            nextfromleft = prevtoleft++;
                        }
                    }
                    //-----------------------------------------------
                    if (prevtoright != 0)
                    {
                        if (evenincrements)
                        {
                            nextfromright += 2;
                        }
                        else
                        {
                            nextfromright = prevtoright++;
                        }
                    }
                    //-----------------------------------------------
                    nexttoleft  += leftincrement;
                    nexttoright += rightincrement;
                    //-----------------------------------------------
                }
                //---------------------------------------------------
                rec.FromLeft  = nextfromleft;
                rec.ToLeft    = nexttoleft;
                rec.FromRight = nextfromright;
                rec.ToRight   = nexttoright;
                //---------------------------------------------------
                prevtoleft  = nexttoleft;
                prevtoright = nexttoright;
                //---------------------------------------------------
            }
            //---------------------------------------------------------
            if (recstored.Length != 0)
            {
                recordStored rec = recstored[recstored.Length - 1];
                if (rec.ToLeft != toleft)
                {
                    rec.ToLeft = toleft;
                }
                if (rec.ToRight != toright)
                {
                    rec.ToRight = toright;
                }
            }
            //---------------------------------------------------------
            return(true);
            //---------------------------------------------------------
        }