Exemplo n.º 1
0
        /// <summary>
        /// Fires the ProgressChanged event.
        /// </summary>
        /// <remarks><para>If the control parameter was given in the constructor of the class, the
        /// event is fired in the context of the calling thread and not of the worker thread.</para></remarks>
        protected virtual void OnProgressChanged()
        {
            //if (m_state == ILAlgorithmState.Unloaded) return;
            ILAlgorithmEventArgs evargs;

            if (String.IsNullOrEmpty(m_lastMessage))
            {
                evargs = new ILAlgorithmEventArgs(m_progress, "Progress: " + ((int)(m_progress * 100)) + "%", m_state);
            }
            else
            {
                evargs = new ILAlgorithmEventArgs(m_progress, m_lastMessage, m_state);
            }
            if (m_control != null && m_control.InvokeRequired && ProgressChanged != null)
            {
                if (!m_control.Disposing && !m_control.IsDisposed && ProgressChanged != null)
                {
                    m_control.Invoke(ProgressChanged, this, evargs);
                }
            }
            else
            {
                if (ProgressChanged != null)
                {
                    ProgressChanged(this, evargs);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// helper function firing the progress changed event
        /// </summary>
        /// <param name="message">string to be send within the
        /// <see cref="ILNumerics.Algorithms.ILAlgorithmEventArgs"/> </param>
        /// <returns>false if a handler of the event has attempted to cancel the
        /// operation, true if the algorithm should continue normaly.</returns>
        protected virtual bool OnProgressChanged(string message)
        {
            ILAlgorithmEventArgs e = new ILAlgorithmEventArgs(m_progress, "Progress:" + message, m_state);

            if (ProgressChanged != null)
            {
                ProgressChanged(this, e);
            }
            if (e.Cancel == true)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// helper function firing the state changed event
        /// </summary>
        /// <param name="message">string to be send within the
        /// <see cref="ILNumerics.Algorithms.ILAlgorithmEventArgs"/> </param>
        /// <returns>false if a handler of the event has attempted to cancel the
        /// operation, true if the algorithm should continue normaly.</returns>
        protected virtual bool OnStateChanged(string message)
        {
            ILAlgorithmEventArgs e = new ILAlgorithmEventArgs(m_progress, "State:" + message, m_state);

            if (StateChanged != null)
            {
                StateChanged(this, e);
            }
            if (e.Cancel == true)
            {
                SetState(ILAlgorithmState.Canceled);
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Fires the StateChanged event.
        /// </summary>
        /// <remarks><para>If the control parameter was given in the constructor of the class, the
        /// event is fired in the context of the calling thread and not of the worker thread.</para></remarks>
        protected virtual void OnStateChanged()
        {
            ILAlgorithmEventArgs evargs = new ILAlgorithmEventArgs(m_progress, "State: " + m_state.ToString(), m_state);

            if (m_control != null && m_control.InvokeRequired)
            {
                if (!m_control.Disposing && !m_control.IsDisposed && StateChanged != null)
                {
                    m_control.Invoke(StateChanged, this, evargs);
                }
            }
            else
            {
                if (StateChanged != null)
                {
                    StateChanged(this, evargs);
                }
            }
        }
Exemplo n.º 5
0
 void bsortConstant_StateChanged(object sender, ILAlgorithmEventArgs e) {
     if (m_stopwatch == null) {
         m_stopwatch = new System.Diagnostics.Stopwatch(); 
     }
     switch (e.State) {
         case ILAlgorithmState.Running: 
             m_stopwatch.Reset(); 
             m_stopwatch.Start();
             break; 
         case ILAlgorithmState.Finished:
             m_stopwatch.Stop(); 
             Info("Last operation finished in: " + m_stopwatch.ElapsedMilliseconds + " ms" + Environment.NewLine); 
             break;
         default: 
             m_stopwatch.Stop(); 
             break; 
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Fires the ProgressChanged event.
 /// </summary>
 /// <remarks><para>If the control parameter was given in the constructor of the class, the 
 /// event is fired in the context of the calling thread and not of the worker thread.</para></remarks>
 protected virtual void OnProgressChanged () {
     //if (m_state == ILAlgorithmState.Unloaded) return; 
     ILAlgorithmEventArgs evargs; 
     if (String.IsNullOrEmpty(m_lastMessage))
         evargs = new ILAlgorithmEventArgs(m_progress,"Progress: " + ((int)(m_progress * 100)) + "%", m_state);
     else 
         evargs = new ILAlgorithmEventArgs(m_progress,m_lastMessage, m_state);
     if (m_control != null && m_control.InvokeRequired && ProgressChanged != null) {
         if (!m_control.Disposing && !m_control.IsDisposed && ProgressChanged != null) {
             m_control.Invoke(ProgressChanged,this, evargs);
         }
     } else {
         if (ProgressChanged != null)
             ProgressChanged(this, evargs); 
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Fires the StateChanged event.
 /// </summary>
 /// <remarks><para>If the control parameter was given in the constructor of the class, the 
 /// event is fired in the context of the calling thread and not of the worker thread.</para></remarks>
 protected virtual void OnStateChanged () {
     ILAlgorithmEventArgs evargs = new ILAlgorithmEventArgs(m_progress,"State: " + m_state.ToString(), m_state);
     if (m_control != null && m_control.InvokeRequired) {
         if (!m_control.Disposing && !m_control.IsDisposed && StateChanged != null) {
             m_control.Invoke(StateChanged,this, evargs);
         }
     } else {
         if (StateChanged != null)
             StateChanged(this, evargs); 
     }
 }
Exemplo n.º 8
0
 void lda_StateChanged(object sender, ILAlgorithmEventArgs e) {
     Info("Got state from " + ((ILAlgorithm) sender).Name + Environment.NewLine + 
          " " + e.Progress + " State: " + e.State); 
 }
Exemplo n.º 9
0
 void lda_ProgressChanged(object sender, ILAlgorithmEventArgs e) {
     Info("Got state from " + ((ILAlgorithm) sender).Name + Environment.NewLine + 
          " " + e.Progress + " State: " + e.State); 
     if (e.Progress > 0.5) {
         e.Cancel = true;
         Info("Cancelling excecution..."); 
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// helper function firing the progress changed event
 /// </summary>
 /// <param name="message">string to be send within the 
 /// <see cref="ILNumerics.Algorithms.ILAlgorithmEventArgs"/> </param>
 /// <returns>false if a handler of the event has attempted to cancel the 
 /// operation, true if the algorithm should continue normaly.</returns>
 protected virtual bool OnProgressChanged (string message) {
     ILAlgorithmEventArgs e = new ILAlgorithmEventArgs(m_progress, "Progress:" + message, m_state);
     if (ProgressChanged != null)
         ProgressChanged(this,e); 
     if (e.Cancel == true) 
         return false; 
     return true;
 }
Exemplo n.º 11
0
 /// <summary>
 /// helper function firing the state changed event
 /// </summary>
 /// <param name="message">string to be send within the 
 /// <see cref="ILNumerics.Algorithms.ILAlgorithmEventArgs"/> </param>
 /// <returns>false if a handler of the event has attempted to cancel the 
 /// operation, true if the algorithm should continue normaly.</returns>
 protected virtual bool OnStateChanged (string message) {
     ILAlgorithmEventArgs e = new ILAlgorithmEventArgs(m_progress, "State:" + message, m_state);
     if (StateChanged != null)
         StateChanged(this,e); 
     if (e.Cancel == true) {
         SetState(ILAlgorithmState.Canceled); 
         return false; 
     }
     return true; 
 }