コード例 #1
0
        public void CloseDocument(Document document)
        {
            int index = OpenDocuments.IndexOf(document);

            OpenDocuments.Remove(document);

            if (index == active_document_index)
            {
                // If there's other documents open, switch to one of them
                if (HasOpenDocuments)
                {
                    if (index > 0)
                    {
                        SetActiveDocument(index - 1);
                    }
                    else
                    {
                        SetActiveDocument(index);
                    }
                }
                else
                {
                    active_document_index = -1;
                    OnActiveDocumentChanged(EventArgs.Empty);
                }
            }

            document.Close();

            OnDocumentClosed(new DocumentEventArgs(document));
        }
コード例 #2
0
        internal void SetActiveDocumentInternal(Document document)
        {
            // Work around a case where we closed a document but haven't updated
            // the active_document_index yet and it points to the closed document
            if (HasOpenDocuments && active_document_index != -1 && OpenDocuments.Count > active_document_index)
            {
                PintaCore.Tools.Commit();
            }

            int index = OpenDocuments.IndexOf(document);

            active_document_index = index;

            OnActiveDocumentChanged(EventArgs.Empty);
        }
コード例 #3
0
        public async void CloseDocument(BaseDocumentViewModel document)
        {
            // TODO: Check if not saved
            int index = OpenDocuments.IndexOf(document);

            if (index != -1)
            {
                OpenDocuments.RemoveAt(index);

                if (index < OpenDocuments.Count)
                {
                    CurrentDocument = OpenDocuments[index];
                }
                else
                {
                    CurrentDocument = OpenDocuments.LastOrDefault();
                }

                if (document.Token != null)
                {
                    await SaveFileTokensAsync();
                }
            }
        }