Exemple #1
0
        public void Calculate()
        {
            foreach (var p in m_variables.Values)
            {
                p.IsProcessed = p.IsInput;
                if (p.IsProcessed == false)
                {
                    p.Value = new fsValue();
                }
            }

            #region Update Handler

            int startCount   = m_variables.Values.Sum(p => p.IsProcessed ? 1 : 0);
            int currentCount = startCount;
            if (m_updateHandler != null)
            {
                m_updateHandler.SetProgress(0);
            }

            #endregion

            bool somethingChanged = true;
            while (somethingChanged)
            {
                somethingChanged = false;
                foreach (var equation in Equations)
                {
                    if (equation.Calculate())
                    {
                        somethingChanged = true;

                        #region Update Handler

                        ++currentCount;
                        if (m_updateHandler != null)
                        {
                            m_updateHandler.SetProgress((double)(currentCount - startCount) / (m_variables.Count - startCount));
                        }

                        #endregion
                    }
                }
            }

            #region Update Handler

            if (m_updateHandler != null)
            {
                m_updateHandler.SetProgress(1);
            }

            #endregion
        }
 public void SetProgress(double progress)
 {
     if (m_parentHandler == null)
     {
         var intProgress = (int)(progress * m_statusControl.Maximum + 0.5);
         m_statusControl.Invoke(
             new fsCallUpdateProgressBar(UpdateProgressBar),
             new object[] { m_statusControl, intProgress });
     }
     else
     {
         m_parentHandler.SetProgress(m_startValue + (m_endValue - m_startValue) * progress);
     }
 }