コード例 #1
0
        /// <summary>
        /// gets a unique export filename
        /// </summary>
        /// <param name="wantedFileName">The filename that should be make unique</param>
        /// <returns>The new unique filename. May be equal the parameter wantedFileName when the name is already unique</returns>
        protected string GetUniqueExportFileName(string wantedFileName)
        {
            if (string.IsNullOrEmpty(wantedFileName))
            {
                return(wantedFileName);
            }
            CheckExportFileNameUniqueVisitor isUniqueVisitor = new CheckExportFileNameUniqueVisitor(wantedFileName);

            EditorManager.Scene.RunShapeVisitor(isUniqueVisitor);
            if (isUniqueVisitor.IsUnique)
            {
                return(wantedFileName);
            }
            //export filename is not unique, so create new unique one
            string searchName;

            char[] chDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
            searchName = wantedFileName.TrimEnd(chDigits);

            GetExportFileNameMaxIndexVisitor maxIndexVisitor = new GetExportFileNameMaxIndexVisitor(searchName, this);

            EditorManager.Scene.RunShapeVisitor(maxIndexVisitor);

            return(searchName + (maxIndexVisitor.MaxIndex + 1).ToString());
        }
コード例 #2
0
    /// <summary>
    /// gets a unique export filename 
    /// </summary>
    /// <param name="wantedFileName">The filename that should be make unique</param>
    /// <returns>The new unique filename. May be equal the parameter wantedFileName when the name is already unique</returns>
    protected string GetUniqueExportFileName(string wantedFileName)
    {
      if (string.IsNullOrEmpty(wantedFileName))
      {
        return wantedFileName;
      }
      CheckExportFileNameUniqueVisitor isUniqueVisitor = new CheckExportFileNameUniqueVisitor(wantedFileName);
      EditorManager.Scene.RunShapeVisitor(isUniqueVisitor);
      if (isUniqueVisitor.IsUnique) 
      {
        return wantedFileName;
      }
      //export filename is not unique, so create new unique one
      string searchName;

      char[] chDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
      searchName = wantedFileName.TrimEnd(chDigits);

      GetExportFileNameMaxIndexVisitor maxIndexVisitor = new GetExportFileNameMaxIndexVisitor(searchName, this);
      EditorManager.Scene.RunShapeVisitor(maxIndexVisitor);

      return searchName + (maxIndexVisitor.MaxIndex + 1).ToString();   
    }