示例#1
0
        private DocumentBase GetDocument(SupportedDocumentInfo docInfo, IDocumentDataContext context, bool activate)
        {
            //Tracer.Verbose("DocumentFactory:GetDocument", "docName{0}, docTitle{0}, docType{0}, activate{0}", docName, docTitle, docType, activate);

            DocumentBase doc = FindDocument(docInfo, context);

            try
            {
                if (doc == null)
                {
                    doc = CreateNewDocument(docInfo, context);
                }

                if (doc != null && activate)
                {
                    _DockManager.ActiveDocument = doc;
                }
            }
            catch (Exception err)
            {
                Tracer.Error("DocumentFactory.GetDocument", err);
            }
            finally
            {
                Tracer.Verbose("DocumentFactory:GetDocument", "END");
            }

            return(doc);
        }
示例#2
0
        public void OpenDocument(DiskContent dc)
        {
            SupportedDocumentInfo info = SupportedDocuments.Find(p => p.Extension == dc.Extension);

            if (info != null)
            {
                IDocumentDataContext context = (IDocumentDataContext)Activator.CreateInstance(info.DocumentDataType);
                context.FullName = dc.FullName;
                GetDocument(info, context, true);
            }
        }
示例#3
0
        private DocumentBase FindDocument(SupportedDocumentInfo docInfo, IDocumentDataContext context)
        {
            IEnumerable <DocumentContent> list = _DockManager.Documents.Where(d => d.Name == docInfo.DocumentContentGUID && d.Title == context.Name);

            if (list.Count() == 1)
            {
                return(list.First() as DocumentBase);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        private DocumentBase CreateNewDocument(SupportedDocumentInfo docInfo, IDocumentDataContext context)
        {
            //Tracer.Verbose("DocumentFactory:CreateDocument", "docName{0}, docTitle{0}, docType{0}, activate{0}", docName, docTitle, docType, activate);

            DocumentBase doc = null;

            try
            {
                doc = (DocumentBase)Activator.CreateInstance(docInfo.DocumentContentType);

                if (doc != null)
                {
                    if (string.IsNullOrEmpty(context.FullName))
                    {
                        doc.Title   = string.Format(docInfo.DefaultTitle, docInfo.Counter++);
                        doc.ToolTip = doc.Title;
                    }
                    doc.Name        = docInfo.DocumentContentGUID;
                    doc.DataContext = context;

                    doc.Closing += new EventHandler <CancelEventArgs>(DocumentClosing);
                    doc.Closed  += new EventHandler(DocumentClosed);

                    _DockManager.MainDocumentPane.Items.Add(doc);
                }
            }
            catch (Exception err)
            {
                Tracer.Error("DocumentFactory.CreateDocument", err);
            }
            finally
            {
                Tracer.Verbose("DocumentFactory:CreateDocument", "END");
            }
            return(doc);
        }
示例#5
0
 public DocumentBase CreateDocument(SupportedDocumentInfo info, IDocumentDataContext context = null)
 {
     return(GetDocument(info, context, true));
 }
示例#6
0
 private DocumentBase GetDocument(SupportedDocumentInfo docInfo)
 {
     return(GetDocument(docInfo, null, true));
 }
示例#7
0
        public void OpenDocument(SupportedDocumentInfo info, IDocumentDataContext context)
        {
            //WorkspaceService.Instance.AddRecentFile(context.FullName);

            GetDocument(info, context, true);
        }