Exemple #1
0
 /// <summary>
 /// CLOSE DOCUMENT
 /// </summary>
 public static void CloseDocument(DocumentViewModel viewModel)
 {
     Documents.Remove(viewModel);
     CheckAllClosed();
 }
Exemple #2
0
        /// <summary>
        /// Current is only set by the following Events
        /// 1.) MainViewModel.Startup Method
        /// 2.) OpenDocument
        /// 3.) DocumentWindow.Enter
        /// 4.) When all documents are closed
        /// </summary>
        private static void QueueCurrent(DocumentViewModel value)
        {
            var complete = true;

            try
            {
                var sw = new Stopwatch(MethodBase.GetCurrentMethod().Name);
                if (_current == value)
                {
                    return;
                }

                if (_current != null &&
                    _current.Model.File.DataController.InvalidateNotificationEvent != null)
                {
                    foreach (var viewModel in DocumentViewModels)
                    {
                        if (viewModel.GetType().Name == "DocumentViewModel")
                        {
                            continue;
                        }
                        _current.Model.File.DataController.InvalidateNotificationEvent -= viewModel.RenderDocument;
                    }
                    _current.Model.File.DataController.InvalidateNotificationEvent -= _current.RenderDocument;
                }

                _current = value;

                if (_current == null)
                {
                    return;
                }

                OutputService.Log($"SET Current for {value.Model.File.Path}");

                foreach (var viewModel in DocumentViewModels)
                {
                    if (viewModel.GetType().Name == "DocumentViewModel")
                    {
                        continue;
                    }
                    _current.Model.File.DataController.InvalidateNotificationEvent += viewModel.RenderDocument;
                }
                _current.Model.File.DataController.InvalidateNotificationEvent += _current.RenderDocument;

                if (!StartupComplete)
                {
                    return;
                }

                // We only Render the Document if 'IsCached' is false OR the first time we render the Document
                // Otherwise we are just setting focus to this document - Sara
                if ((!_current.IsCached || !_current.FirstRenderComplete) & !_current.IsRendering)
                {
                    _current.RenderDocument();
                    complete = false;
                }

                RenderViews();

                PrepareHideOptions();

                sw.Stop();
            }
            finally
            {
                if (complete)
                {
                    _queue.ItemComplete();
                }
            }
        }