Exemplo n.º 1
0
        public void app_ClosingLinks(object sender, ProgressChangedEventArgs e)
        {
            if (Globals.data != null)
            {
//        var openingLinksNames = new List<string>();
//        foreach (ModelPath modelPath in Globals.data)
//        {
//          var filePath = ModelPathUtils.ConvertModelPathToUserVisiblePath(modelPath);
//          openingLinksNames.Add(Path.GetFileNameWithoutExtension(filePath));
//        }
                // get document from event args
//        if (openingLinksNames.Any(file => e.Caption.Contains(file)))
                var state = e.Caption;
                if ((state.StartsWith("Loading") || state.StartsWith("Загрузка")) && !state.Contains(Globals.data))
                {
//          if (file.Length > 0)
//          {
//            if (!state.Contains(Globals.data))
//            {
                    if (e.Cancellable)
                    {
                        Debug.Write(state);
                        e.Cancel();
                    }
//            }
//          }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add event data
        /// </summary>
        /// <param name="progressEvent"></param>
        /// <returns></returns>
        public ProgressItem AddEventData(Autodesk.Revit.DB.Events.ProgressChangedEventArgs progressEvent)
        {
            ProgressItem currentProgressItem = null;


            switch (progressEvent.Stage)
            {
            case ProgressStage.Started:
            {
                ProgressItem pi = new ProgressItem(progressEvent.Caption, progressEvent.LowerRange, progressEvent.UpperRange, progressEvent.Position, progressEvent.Stage);
                m_itemStack.Push(pi);
                currentProgressItem = pi;
                break;
            }

            case ProgressStage.PositionChanged:
            {
                ProgressItem pi = m_itemStack.Peek();
                if (pi.Name != progressEvent.Caption)
                {
                    Debug.WriteLine("Name not matching?");
                }
                pi.Position         = progressEvent.Position;
                pi.Stage            = progressEvent.Stage;
                currentProgressItem = pi;
                break;
            }

            case ProgressStage.RangeChanged:
            {
                ProgressItem pi = m_itemStack.Peek();
                pi.Upper            = progressEvent.UpperRange;
                pi.Stage            = progressEvent.Stage;
                currentProgressItem = pi;
                break;
            }

            case ProgressStage.Finished:
            {
                ProgressItem pi = m_itemStack.Pop();
                pi.IsDone           = true;
                pi.Stage            = progressEvent.Stage;
                currentProgressItem = pi;
                break;
            }

            case ProgressStage.CaptionChanged:
            {
                ProgressItem pi = m_itemStack.Peek();
                pi.Name  = progressEvent.Caption;
                pi.Stage = progressEvent.Stage;
                Debug.WriteLine("Caption Change at top.");
                currentProgressItem = pi;
                break;
            }

            case ProgressStage.Unchanged:
            {
                Debug.WriteLine("Idle.");
                currentProgressItem = new ProgressItem(progressEvent.Caption, progressEvent.LowerRange, progressEvent.UpperRange, progressEvent.Position, progressEvent.Stage);
                break;
            }


            default:
                throw new Exception("Unknown stage.");
            }


            if (m_itemStack.Count == 0)
            {
                Debug.WriteLine("Stack empty");
            }
            else
            {
                Debug.WriteLine(this.ToString());
            }

            return(currentProgressItem);
        }