Exemplo n.º 1
0
        private static void Process(Store store, string filename, AssemblyProcessor assemblyProcessor, TextFileProcessor textFileProcessor)
        {
            try
            {
                Cursor.Current          = Cursors.WaitCursor;
                ModelRoot.BatchUpdating = true;

                if (IsAssembly(filename))
                {
                    using (Transaction tx = store.TransactionManager.BeginTransaction("Process dropped assembly"))
                    {
                        if (assemblyProcessor.Process(filename))
                        {
                            StatusDisplay.Show("Creating diagram elements. This might take a while...");
                            tx.Commit();

                            ModelDisplay.LayoutDiagram(store.ModelRoot().GetActiveDiagram() as EFModelDiagram);
                        }
                    }
                }
                else
                {
                    using (Transaction tx = store.TransactionManager.BeginTransaction("Process dropped class"))
                    {
                        if (textFileProcessor.Process(filename))
                        {
                            StatusDisplay.Show("Creating diagram elements. This might take a while...");
                            tx.Commit();
                        }
                    }
                }
            }
            finally
            {
                Cursor.Current          = Cursors.Default;
                ModelRoot.BatchUpdating = false;

                StatusDisplay.Show("");
            }
        }
Exemplo n.º 2
0
        private static IEnumerable <ModelElement> Process(Store store, string filename, AssemblyProcessor assemblyProcessor, TextFileProcessor textFileProcessor)
        {
            List <ModelElement> newElements;
            Cursor prev = Cursor.Current;

            try
            {
                Cursor.Current          = Cursors.WaitCursor;
                ModelRoot.BatchUpdating = true;

                using (Transaction tx = store.TransactionManager.BeginTransaction("Process drop"))
                {
                    bool processingResult = IsAssembly(filename)
                                          ? assemblyProcessor.Process(filename, out newElements)
                                          : textFileProcessor.Process(filename, out newElements);

                    if (processingResult)
                    {
                        StatusDisplay.Show("Creating diagram elements. This might take a while...");
                        tx.Commit();
                    }
                    else
                    {
                        newElements = new List <ModelElement>();
                    }
                }
            }
            finally
            {
                Cursor.Current          = prev;
                ModelRoot.BatchUpdating = false;

                StatusDisplay.Show("Ready");
            }

            return(newElements);
        }