예제 #1
0
파일: Document.cs 프로젝트: perryiv/cadkit
 /// <summary>
 /// Read the file.
 /// </summary>
 void CadKit.Interfaces.IFileOpen.open(string name, object caller)
 {
     using (this.Lock.write())
     {
         CadKit.Interfaces.IProgressBar progress = caller as CadKit.Interfaces.IProgressBar;
         if (null != progress)
         {
             int total = progress.Range;
             for (int i = 0; i < total; ++i)
             {
                 progress.Value = i;
                 System.Threading.Thread.Sleep(1000);
             }
             progress.Value = total;
         }
     }
 }
예제 #2
0
파일: Progress.cs 프로젝트: perryiv/cadkit
        /// <summary>
        /// Report progress if possible.
        /// </summary>
        public static void notify(string text, int value, int total, object caller)
        {
            lock ("CadKit.Tools.Progress.notify")
            {
                CadKit.Interfaces.IProgressBar progress = caller as CadKit.Interfaces.IProgressBar;
                if (null != progress)
                {
                    progress.Text = (null != text) ? text : "";
                    float v        = value;
                    float t        = total;
                    float fraction = v / t;
                    float position = fraction * progress.Range;
                    progress.Value = (int)position;
                }

                CadKit.Interfaces.IUpdateDisplay update = caller as CadKit.Interfaces.IUpdateDisplay;
                if (null != update)
                {
                    update.updateDisplay();
                }
            }
        }