示例#1
0
        /// <summary>
        /// Get the filter string (used especially with browse dialogs) according to the specified types
        /// </summary>
        /// <param name="documentTypes">The types to use to build the filter string</param>
        /// <param name="descriptiveName">The descriptive name to use for the filter</param>
        /// <returns>The filter string</returns>
        public string GetDocumentFilter(List <Type> documentTypes, string descriptiveName)
        {
            string descriptiveFilter = descriptiveName + " (";
            string filterString      = string.Empty;

            foreach (Type type in documentTypes)
            {
                if (_registeredDocumentTypesByType.ContainsKey(type))
                {
                    DocumentTypeDescriptor docTypeDesc = _registeredDocumentTypesByType[type];

                    if (docTypeDesc.Extension != string.Empty)
                    {
                        if (descriptiveFilter != string.Empty)
                        {
                            descriptiveFilter += " ";
                        }

                        descriptiveFilter += "*" + docTypeDesc.Extension + ";";
                        filterString      += "*" + docTypeDesc.Extension + ";";
                    }
                }
            }

            // Remove extra useless ';' character
            descriptiveFilter = descriptiveFilter.Substring(0, descriptiveFilter.Length - 1);
            filterString      = filterString.Substring(0, filterString.Length - 1);

            // Concatenate both actual filters and descriptive name
            filterString = descriptiveFilter += ")|" + filterString;

            return(filterString);
        }
示例#2
0
        /// <summary>
        /// Register a new document type to the document factory
        /// </summary>
        /// <param name="documentType">The type of document to register</param>
        /// <param name="extension">The associated extension to associate with the provided type</param>
        /// <param name="descriptiveName">The associated descriptive name to associate with the provided type</param>
        /// <returns>The create document type descriptor</returns>
        public DocumentTypeDescriptor RegisterDocumentType(Type documentType, string extension, string descriptiveName)
        {
            DocumentTypeDescriptor newDocumentType = new DocumentTypeDescriptor(documentType, extension, descriptiveName);

            if (extension != string.Empty)
            {
                _registeredDocumentTypesByExt.Add(extension, newDocumentType);
            }
            _registeredDocumentTypesByType.Add(documentType, newDocumentType);
            return(newDocumentType);
        }
示例#3
0
        private ILuaEditDocument CreateDocumentByDocumentRef(IDocumentRef docRef)
        {
            DocumentTypeDescriptor type = _registeredDocumentTypesByExt[Path.GetExtension(docRef.FileName)];

            if (type != null)
            {
                return(Activator.CreateInstance(type.DocumentType, new object[] { docRef }) as ILuaEditDocument);
            }

            return(null);
        }
示例#4
0
        /// <summary>
        /// Register a new document type to the document factory
        /// </summary>
        /// <param name="documentType">The type of document to register</param>
        /// <param name="extension">The associated extension to associate with the provided type</param>
        /// <param name="descriptiveName">The associated descriptive name to associate with the provided type</param>
        /// <param name="smallImage">The small image associated with that type of document</param>
        /// <param name="largeImage">The large image associated with that type of document</param>
        /// <param name="stateImage">The state image associated with that type of document</param>
        /// <returns>The create document type descriptor</returns>
        public DocumentTypeDescriptor RegisterDocumentType(Type documentType, string extension, string descriptiveName,
                                                           Bitmap smallImage, Bitmap largeImage, Bitmap stateImage)
        {
            int smallImageIndex = _documentSmallImages.Images.Add(smallImage, smallImage.GetPixel(0, 0));
            int largeImageIndex = _documentLargeImages.Images.Add(largeImage, largeImage.GetPixel(0, 0));
            int stateImageIndex = _documentSmallImages.Images.Add(stateImage, stateImage.GetPixel(0, 0));

            DocumentTypeDescriptor newDocumentType = new DocumentTypeDescriptor(documentType, extension,
                                                                                descriptiveName, smallImageIndex,
                                                                                largeImageIndex, stateImageIndex);

            if (!string.IsNullOrEmpty(extension))
            {
                _registeredDocumentTypesByExt.Add(extension, newDocumentType);
            }

            _registeredDocumentTypesByType.Add(documentType, newDocumentType);

            return(newDocumentType);
        }