コード例 #1
0
        /// <include file='doc\Form.uex' path='docs/doc[@for="Form.GetLinkedForms"]/*' />
        public IList GetLinkedForms(int optimumPageWeight)
        {
            // Always add itself to the list as the first one
            UniqueSet set = new UniqueSet();

            set.Add(this);

            // If the form has a deactivate handler, then we
            // can't send the form with linked forms, because server interaction
            // is necessary to move between forms.

            if (HasDeactivateHandler())
            {
                return(set);
            }

            // Will stop once no new forms are added in a pass, or has
            // reached the optimum page weight.

            int totalWeight = 0;
            int i;

            // negative means the caller doesn't care about the weight
            bool checkWeight = optimumPageWeight >= 0;

            for (i = 0; i < set.Count; i++)
            {
                Form form = (Form)set[i];

                if (checkWeight)
                {
                    totalWeight += form.GetVisibleWeight();
                    if (totalWeight > optimumPageWeight)
                    {
                        break;
                    }
                }
                form.AddLinkedForms(set);
            }

            // More forms may have been linked than the total weight allows.
            // Remove these.

            if (i != 0 &&  // i == 0 means only one form is in the list
                i < set.Count)
            {
                for (int j = set.Count - 1; j >= i; j--)
                {
                    set.RemoveAt(j);
                }
            }

            return(set);
        }
コード例 #2
0
ファイル: Form.cs プロジェクト: iskiselev/JSIL.NetFramework
        /// <include file='doc\Form.uex' path='docs/doc[@for="Form.GetLinkedForms"]/*' />
        public IList GetLinkedForms(int optimumPageWeight)
        {
            // Always add itself to the list as the first one
            UniqueSet set = new UniqueSet();
            set.Add(this);

            // If the form has a deactivate handler, then we
            // can't send the form with linked forms, because server interaction
            // is necessary to move between forms.

            if (HasDeactivateHandler())
            {
                return set;
            }

            // Will stop once no new forms are added in a pass, or has
            // reached the optimum page weight.

            int totalWeight = 0;
            int i;

            // negative means the caller doesn't care about the weight
            bool checkWeight = optimumPageWeight >= 0;

            for (i = 0; i < set.Count; i++)
            {
                Form form = (Form)set[i];

                if (checkWeight)
                {
                    totalWeight += form.GetVisibleWeight();
                    if (totalWeight > optimumPageWeight)
                    {
                        break;
                    }
                }
                form.AddLinkedForms(set);
            }

            // More forms may have been linked than the total weight allows.
            // Remove these.

            if (i != 0 &&  // i == 0 means only one form is in the list
                i < set.Count)
            {
                for (int j = set.Count - 1; j >= i; j--)
                {
                    set.RemoveAt(j);
                }
            }

            return set;
        }