コード例 #1
0
        public override string FindFile(
            string fileName,
            Database database,
            FindFileHint hint)
        {
            // add extension if not already part of the file name
            if (!fileName.Contains("."))
            {
                string extension;
                switch (hint)
                {
                case FindFileHint.CompiledShapeFile:
                    extension = ".shx";
                    break;

                case FindFileHint.TrueTypeFontFile:
                    extension = ".ttf";
                    break;

                case FindFileHint.PatternFile:
                    extension = ".pat";
                    break;

                case FindFileHint.ArxApplication:
                    extension = ".dbx";
                    break;

                case FindFileHint.FontMapFile:
                    extension = ".fmp";
                    break;

                case FindFileHint.XRefDrawing:
                    extension = ".dwg";
                    break;

                // Fall through. These could have
                // various extensions
                case FindFileHint.FontFile:
                case FindFileHint.EmbeddedImageFile:
                default:
                    extension = "";
                    break;
                }

                fileName += extension;
            }

            // add it to the unresolved items if it could not be resolved
            return(SearchPath(fileName));
        }
コード例 #2
0
        /// <summary>
        /// This method is called by the database code when it is trying to locate a file.
        /// There is no default implementation. The RealDWG host application must override this method.
        /// The database will sometimes pass you a FindFileHint that you may use to narrow your search.
        /// Refer to ObjectArx document for more information.
        /// </summary>
        /// <param name="fileName">Given name of tghe file to find.</param>
        /// <param name="database">This will give you the path of the DWG file associated with the database.</param>
        /// <param name="hint">Caller may pass a hint used to narrow the search.</param>
        /// <returns></returns>
        public override string FindFile(string fileName, Database database, FindFileHint hint)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                return(null);
            }

            var extension = String.Empty;

            // add extension if needed
            if (!fileName.Contains("."))
            {
                switch (hint)
                {
                case FindFileHint.CompiledShapeFile:
                    extension = /*MSG0*/ ".shx";
                    break;

                case FindFileHint.TrueTypeFontFile:
                    extension = /*MSG0*/ ".ttf";
                    break;

                case FindFileHint.PatternFile:
                    extension = /*MSG0*/ ".pat";
                    break;

                case FindFileHint.ArxApplication:
                    extension = /*MSG0*/ ".dbx";
                    break;

                case FindFileHint.FontMapFile:
                    extension = /*MSG0*/ ".fmp";
                    break;

                case FindFileHint.XRefDrawing:
                    extension = /*MSG0*/ ".dwg";
                    break;

                // Fall through. These could have various extensions
                case FindFileHint.FontFile:
                case FindFileHint.EmbeddedImageFile:
                default:
                    extension = "";
                    break;
                }
                fileName += extension;
            }
            return(SearchPath(fileName));
        }
コード例 #3
0
 /// <summary>
 /// This method is called by the database code when it is trying to locate a file.
 /// There is no default implementation. The RealDWG host application must override
 /// this method. The database will sometimes pass a FindFileHint that can be used
 /// to narrow the search. Refer to ObjectArx document for more information.
 /// </summary>
 /// <param name="fileName">Given name of the file to find.</param>
 /// <param name="database">The path of the DWG file associated with the database.</param>
 /// <param name="hint">Caller may pass a hint used to narrow the search.</param>
 /// <returns>The full path to the file.</returns>
 public override string FindFile(string fileName, Database database, FindFileHint hint)
 {
     return("");
 }
コード例 #4
0
        public override string FindFile(string file, Database db, FindFileHint hint)
        {
            string sFile = this.FindFileEx(file, db, hint);

            if (sFile.Length > 0)
            {
                return(sFile);
            }

            string strFileName = file;
            string ext;

            if (strFileName.Length > 3)
            {
                ext = strFileName.Substring(strFileName.Length - 4, 4).ToUpper();
            }
            else
            {
                ext = file.ToUpper();
            }
            if (ext == string.Format(".PC3"))
            {
                return(FindConfigFile(string.Format("PrinterConfigDir"), file));
            }
            if (ext == string.Format(".STB") || ext == string.Format(".CTB"))
            {
                return(FindConfigFile(string.Format("PrinterStyleSheetDir"), file));
            }
            if (ext == string.Format(".PMP"))
            {
                return(FindConfigFile(string.Format("PrinterDescDir"), file));
            }

            switch (hint)
            {
            case FindFileHint.FontFile:
            case FindFileHint.CompiledShapeFile:
            case FindFileHint.TrueTypeFontFile:
            case FindFileHint.PatternFile:
            case FindFileHint.FontMapFile:
            case FindFileHint.TextureMapFile:
                break;

            default:
                return(sFile);
            }

            if (hint != FindFileHint.TextureMapFile && ext != string.Format(".SHX") && ext != string.Format(".PAT") && ext != string.Format(".TTF") && ext != string.Format(".TTC"))
            {
                strFileName += string.Format(".shx");
            }
            else if (hint == FindFileHint.TextureMapFile)
            {
                strFileName.Replace(string.Format("/"), string.Format("\\"));
                int last = strFileName.LastIndexOf("\\");
                strFileName = strFileName.Substring(0, last);
            }


            sFile = (hint != FindFileHint.TextureMapFile) ? GetRegistryACADFromProfile() : GetRegistryAVEMAPSFromProfile();
            while (sFile.Length > 0)
            {
                int    nFindStr = sFile.IndexOf(";");
                string sPath;
                if (-1 == nFindStr)
                {
                    sPath = sFile;
                    sFile = string.Format("");
                }
                else
                {
                    sPath = string.Format("{0}\\{1}", sFile.Substring(0, nFindStr), strFileName);
                    if (dd.AccessFileRead(sPath))
                    {
                        return(sPath);
                    }
                    sFile = sFile.Substring(nFindStr + 1, sFile.Length - nFindStr - 1);
                }
            }

            if (hint == FindFileHint.TextureMapFile)
            {
                return(sFile);
            }

            if (sFile.Length <= 0)
            {
                string sAcadLocation = GetRegistryAcadLocation();
                if (sAcadLocation.Length > 0)
                {
                    sFile = string.Format("{0}\\Fonts\\{1}", sAcadLocation, strFileName);
                    if (dd.AccessFileRead(sFile))
                    {
                        sFile = string.Format("{0}\\Support\\{1}", sAcadLocation, strFileName);
                        if (dd.AccessFileRead(sFile))
                        {
                            sFile = string.Format("");
                        }
                    }
                }
            }
            return(sFile);
        }
コード例 #5
0
ファイル: HostAppServ.cs プロジェクト: mzh3511/VectorDrawApp
        public override string FindFile(string file, Database db, FindFileHint hint)
        {
            var sFile = this.FindFileEx(file, db, hint);

            if (sFile.Length > 0)
            {
                return(sFile);
            }

            var strFileName = file;
            var ext         = strFileName.Length > 3 ? strFileName.Substring(strFileName.Length - 4, 4).ToUpper() : file.ToUpper();

            switch (ext)
            {
            case ".PC3":
                return(FindConfigFile("PrinterConfigDir", file));

            case ".STB":
            case ".CTB":
                return(FindConfigFile("PrinterStyleSheetDir", file));

            case ".PMP":
                return(FindConfigFile("PrinterDescDir", file));
            }

            switch (hint)
            {
            case FindFileHint.FontFile:
            case FindFileHint.CompiledShapeFile:
            case FindFileHint.TrueTypeFontFile:
            case FindFileHint.PatternFile:
            case FindFileHint.FontMapFile:
            case FindFileHint.TextureMapFile:
                break;

            default:
                return(sFile);
            }

            if (hint != FindFileHint.TextureMapFile && ext != ".SHX" && ext != ".PAT" && ext != ".TTF" && ext != ".TTC")
            {
                strFileName += ".shx";
            }
            else if (hint == FindFileHint.TextureMapFile)
            {
                strFileName.Replace("/", "\\");
                var last = strFileName.LastIndexOf("\\");
                strFileName = last == -1 ? "" : strFileName.Substring(0, last);
            }


            sFile = (hint != FindFileHint.TextureMapFile) ? GetRegistryACADFromProfile() : GetRegistryAVEMAPSFromProfile();
            while (sFile.Length > 0)
            {
                var    nFindStr = sFile.IndexOf(";");
                string sPath;
                if (-1 == nFindStr)
                {
                    sPath = sFile;
                    sFile = "";
                }
                else
                {
                    sPath = $"{sFile.Substring(0, nFindStr)}\\{strFileName}";
                    if (System.IO.File.Exists(sPath))
                    {
                        return(sPath);
                    }
                    sFile = sFile.Substring(nFindStr + 1, sFile.Length - nFindStr - 1);
                }
            }

            if (hint == FindFileHint.TextureMapFile)
            {
                return(sFile);
            }

            if (sFile.Length <= 0)
            {
                var sAcadLocation = GetRegistryAcadLocation();
                if (sAcadLocation.Length > 0)
                {
                    sFile = $"{sAcadLocation}\\Fonts\\{strFileName}";
                    if (System.IO.File.Exists(sFile))
                    {
                        sFile = $"{sAcadLocation}\\Support\\{strFileName}";
                        if (System.IO.File.Exists(sFile))
                        {
                            sFile = "";
                        }
                    }
                }
            }
            return(sFile);
        }
コード例 #6
0
        public override string FindFile(
            string fileName,
            Database database,
            FindFileHint hint)
        {
            if (!MyDebugger.isOverriden("FindFile", fileName))
            {
                return(MyDebugger.logReturn(""));
            }

            // avoid repeated search for unresolvable files
            // file names cannot contain the pipe character "|", that's why we use it
            if (mUnresolved.Contains(fileName + "|" + hint.ToString()))
            {
                return(MyDebugger.logReturn(""));
            }

            // add extension if not already part of the file name
            if (!fileName.Contains("."))
            {
                string extension;
                switch (hint)
                {
                case FindFileHint.CompiledShapeFile:
                    extension = ".shx";
                    break;

                case FindFileHint.TrueTypeFontFile:
                    extension = ".ttf";
                    break;

                case FindFileHint.PatternFile:
                    extension = ".pat";
                    break;

                case FindFileHint.ArxApplication:
                    extension = ".dbx";
                    break;

                case FindFileHint.FontMapFile:
                    extension = ".fmp";
                    break;

                case FindFileHint.XRefDrawing:
                    extension = ".dwg";
                    break;

                // Fall through. These could have
                // various extensions
                case FindFileHint.FontFile:
                case FindFileHint.EmbeddedImageFile:
                default:
                    extension = "";
                    break;
                }

                fileName += extension;
            }

            // add it to the unresolved items if it could not be resolved
            string ret = SearchPath(fileName);

            if (ret == "")
            {
                mUnresolved.Add(fileName + "|" + hint.ToString());
            }

            return(MyDebugger.logReturn(ret));
        }