Ejemplo n.º 1
0
        private void dataGridDocuments_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var di = dataGridDocuments.Rows[e.RowIndex].DataBoundItem as SessionDocumentDto;

            if (di != null)
            {
                _dteAdapter.OpenFile(di.Path, di.Type);
            }
        }
Ejemplo n.º 2
0
        public void LoadDocumentsFromSession(Session session)
        {
            try
            {
                bool cancelled = false;

                var localClosedDocs = new List <SessionDocument>();

                var documents = new List <SessionDocument>(session.GetDocuments());

                foreach (var window in _dteAdapter.GetWindowsForValidDocuments())
                {
                    int index = -1;
                    for (int i = 0; i < documents.Count; i++)
                    {
                        if (window.DocumentMatches(documents[i]))
                        {
                            index = i;
                            break;
                        }
                    }

                    if (index < 0)
                    {
                        string       fullPath     = window.FullPath;
                        DocumentType documentType = window.DocumentType;

                        if (!window.Close(SaveChanges.Prompt))
                        {
                            cancelled = true;
                            break;
                        }
                        else
                        {
                            localClosedDocs.Insert(0, new SessionDocument(fullPath, documentType));
                        }
                    }
                    else
                    {
                        documents.RemoveAt(index);
                    }
                }

                if (localClosedDocs.Count > 0)
                {
                    AddDocumentsToRecentlyClosedList(_recentlyClosedDocs, localClosedDocs);
                }

                if (!cancelled)
                {
                    StringBuilder errors = new StringBuilder();
                    foreach (SessionDocument document in documents)
                    {
                        if (!_dteAdapter.FileExists(document.Path))
                        {
                            errors.AppendLine(document.Path);
                        }
                        else
                        {
                            _dteAdapter.OpenFile(document.Path, document.Type);
                        }
                    }

                    if (errors.Length > 0)
                    {
                        _viewAdapter.ShowLongMessage("Warning", "The following documents could not be found", errors.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                _exceptionManager.HandleException(ex);
            }
        }