Esempio n. 1
0
 /// <summary>
 /// Manage the adding of forms to our internal arrays
 /// </summary>
 /// <param name="holder"></param>
 static private void AddForm(FormHolder holder)
 {
     if (holder != null)
     {
         mForms[(int)holder.mDepthZone].Add(holder.mDepth, holder);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Manage the removing of forms to our internal arrays
 /// </summary>
 /// <param name="holder"></param>
 static private void RemoveForm(FormHolder holder)
 {
     if (holder != null)
     {
         mForms[(int)holder.mDepthZone].Remove(holder.mDepth);
     }
 }
        public override void Create(FormHolder Parent)
        {
            SetSize(ValueField.Size + new Vector2(Font.MeasureString(Name).X, 0));

            if (!NoValue)
            {
                LinkedList <Form> Forms = new LinkedList <Form>();
                Dictionary <string, LinkedList <BasicEffectParameter> > Values = new Dictionary <string, LinkedList <BasicEffectParameter> >();

                foreach (EffectValue e in ReferenceValues)
                {
                    foreach (BasicEffectParameter v in e.Parameters.Values)
                    {
                        LinkedList <BasicEffectParameter> Vlist = null;
                        if (!Values.Keys.Contains(v.Name))
                        {
                            Values.Add(v.Name, Vlist = new LinkedList <BasicEffectParameter>());
                        }
                        else
                        {
                            Vlist = Values[v.Name];
                        }

                        Vlist.AddLast(v);
                    }
                }

                foreach (string s in Values.Keys)
                {
                    Parent.AddForm(Values[s].First.Value.GetForm(Values[s]));
                }
            }

            base.Create(Parent);
        }
Esempio n. 4
0
        /// <summary>
        /// Main Show routine
        /// </summary>
        static private DialogResult Show(Form parent, Form child, FormDepth depth, bool isModal, bool isVirtual)
        {
            DialogResult result = DialogResult.None;
            FormHolder   holder = CreateFormHolder(child, depth, isModal);

            AddForm(holder);

            try
            {
                holder.mForm.StartPosition = FormStartPosition.CenterParent;

                if (isVirtual)
                {
                    // this is a virtually modal form
                    if (parent != null)
                    {
                        parent.Invoke(new DisableParentDelegate(DisableParent), new object[] { parent });
                    }

                    if (!isModal)
                    {
                        holder.mForm.Show();
                    }
                }
                else
                {
                    if (isModal)
                    {
                        //this is a pure modal form
                        result = holder.mForm.ShowDialog(parent);
                        Close(holder.mForm);
                    }
                    else
                    {
                        // this is not modal nor is it virtually modal, so just show it modeless
                        holder.mForm.Show();
                    }
                }
            }
            // Ignore any ThreadAbortExceptions (but keep this code here so we can observe them)
            catch (ThreadAbortException ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                // If we've caught, re-enable our parent (just in case)
                if (parent != null)
                {
                    //Debug.WriteLine(parent.Name + " - (Exception)BackForm ReEnabled", "Show");
                    parent.Enabled = true;
                }
            }

            return(result);
        }
Esempio n. 5
0
        static private int GetTopmostDepth()
        {
            FormHolder holder = GetTopmostFormHolder();

            if (holder != null)
            {
                return(holder.mDepth);
            }

            return(-1);
        }
Esempio n. 6
0
        static private Form GetTopmostForm()
        {
            FormHolder holder = GetTopmostFormHolder();

            if (holder != null)
            {
                return(holder.mForm);
            }

            return(null);
        }
        public override void Create(FormHolder Parent)
        {
            Vector2 Size = Font.MeasureString(Name) + new Vector2(0, ValueForm.Buffer * 4 + YHolder.ValueField.Size.Y + ZHolder.ValueField.Size.Y + WHolder.ValueField.Size.Y);

            foreach (Form f in FormChildren)
                Size.X = Math.Max(f.Size.X, Size.X);

            SetSize(Size);

            base.Create(Parent);
        }
Esempio n. 8
0
        /// <summary>
        /// Bring the highest form to the top of our window
        /// </summary>
        static private void BringNextToTop()
        {
            //Only go in there if nobody else is doing it already
            //The first person in here will go through the loop and activate all the windows in the order they should be.
            //Anytime we get here and the mutex is locked, this is being called from a form that is not
            //the original one being activated so we don't have to worry about reactivating all the windows again
            if (mutex.WaitOne(0, false))
            {
                try
                {
                    //if (mCurrentTopmost == null || GetTopmostDepth() > mCurrentTopmost.mDepth)
                    {
                        mCurrentTopmost = GetTopmostFormHolder();
#if true
                        //Don't keep activating the same form over and over
                        if (mCurrentTopmost != null)
                        {
                            //Debug.WriteLine("+++Activate: " + mCurrentTopmost.mForm.Name);

                            mCurrentTopmost.mForm.Enabled = true;
                            mCurrentTopmost.mForm.Activate();
                        }
#else
                        for (int i = 0; i < mForms.Length; i++)
                        {
                            for (int j = 0; j < mForms[i].Count; j++)
                            {
                                // I assume the latest node in our sorted list is the highest because it is a sorted (by depth) list
                                FormHolder holder = mForms[i].GetByIndex(j) as FormHolder;

                                //Debug.WriteLine("+++Activate: " + holder.mForm.Name);

                                if (holder == GetTopmostFormHolder())
                                {
                                    holder.mForm.Enabled = true;
                                }

                                holder.mForm.Activate();
                                holder.mForm.BringToFront();
                            }
                        }
#endif
                    }
                }
                catch
                {
                }
                finally
                {
                    mutex.ReleaseMutex();
                }
            }
        }
Esempio n. 9
0
        static private FormHolder GetTopmostFormHolder()
        {
            //Go backwards through the list of active forms to find the topmost one
            for (int i = mForms.Length - 1; i >= 0; i--)
            {
                if (mForms[i].Count > 0)
                {
                    // I assume the latest node in our sorted list is the highest because it is a sorted (by depth) list
                    FormHolder holder = mForms[i].GetByIndex(mForms[i].Count - 1) as FormHolder;
                    return(holder);
                }
            }

            return(null);
        }
Esempio n. 10
0
        /// <summary>
        /// Bring the highest form to the top of our window
        /// </summary>
        static private Form GetTopmostForm(FormDepth zone)
        {
            // I assume the latest node in our sorted list is the highest because it is a sorted(by depth) list
            for (int z = (int)zone; z >= 0; z--)
            {
                if (mForms[z].Count > 0)
                {
                    // I assume the latest node in our sorted list is the highest because it is a sorted(by depth) list
                    FormHolder holder = mForms[z].GetByIndex(mForms[z].Count - 1) as FormHolder;
                    return(holder.mForm);
                }
            }

            return(null);
        }
Esempio n. 11
0
        static private FormHolder RemoveHolderMap(Form form)
        {
            FormHolder holder = null;

            //Go through all the map entries in the list
            foreach (FormMap map in mFormMapList)
            {
                if (map.form == form)
                {
                    //This is it, get the holder so we can return it, and then remove the map entry
                    holder = map.holder;
                    mFormMapList.Remove(map);
                    break;
                }
            }

            return(holder);
        }
Esempio n. 12
0
        /// <summary>
        /// Close function
        /// </summary>
        /// <param name="form"></param>
        static private void Close(Form form)
        {
            try
            {
                // Get our holder hande from the closing form
                FormHolder holder = RemoveHolderMap(form);

                // Remove this from our sorted set
                RemoveForm(holder);

                if (holder == mCurrentTopmost)
                {
                    //This form is going to be closed, so it cannot be the topmost anymore
                    mCurrentTopmost = null;
                }

                // Find out who is next in line to be enabled
                BringNextToTop();
            }
            catch
            {
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Create a formHolder object with the correct depth and event handlers
        /// </summary>
        /// <param name="form"></param>
        /// <param name="depth"></param>
        /// <returns></returns>
        static private FormHolder CreateFormHolder(Form form, FormDepth depth, bool isModal)
        {
            // Create our handle
            FormHolder holder = new FormHolder();

            // Assign it our vars
            holder.mForm      = form;
            holder.mDepthZone = depth;
            holder.mModal     = isModal;

            // Determine its depth base on its zone
            switch (depth)
            {
            case FormDepth.BACK:
                holder.mDepth = mCurrentBack++;
                break;

            case FormDepth.MID:
                holder.mDepth = mCurrentMid++;
                break;

            case FormDepth.TOP:
                holder.mDepth = mCurrentTop++;
                break;
            }

            // Mark down in our list that this holder goes with this form
            AddHolderMap(form, holder);

            // Override the forms activated event handle
            form.Activated += new EventHandler(form_Activated);
            form.Closed    += new EventHandler(form_Closed);

            // Return the new object
            return(holder);
        }
        public override void Create(FormHolder Parent)
        {
            SetSize(ValueField.Size + new Vector2(Font.MeasureString(Name).X, 0));

            base.Create(Parent);
        }
Esempio n. 15
0
        /// <summary>
        /// Assign the initial parent form
        /// </summary>
        /// <param name="form"></param>
        /// <param name="depth"></param>
        static public void InitParent(Form form, FormDepth depth)
        {
            FormHolder holder = CreateFormHolder(form, depth, false);

            AddForm(holder);
        }
Esempio n. 16
0
 static private void AddHolderMap(Form form, FormHolder holder)
 {
     mFormMapList.Add(new FormMap(form, holder));
 }
Esempio n. 17
0
 public FormMap(Form form, FormHolder holder)
 {
     this.form   = form;
     this.holder = holder;
 }