示例#1
0
 /// <summary>
 /// 检查是否绝对路径
 /// </summary>
 /// <param name="Path"></param>
 /// <returns></returns>
 public static bool IsAbsolutePath(string Path)
 {
     if (HyStringUtility.IsStringEmpty(Path))
     {
         return(false);
     }
     if (Path.Contains(@":\"))
     {
         return(true);
     }
     return(false);
 }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="animString"></param>
        /// <returns></returns>
        public static string[] ParseAnimString(string animString)
        {
            if (IsStringEmpty(animString))
            {
                return(null);
            }

            List <string> strList = new List <string>();
            int           pos     = animString.IndexOf('|');

            if (pos < 0)
            {
                //如果文件不包含扩展名,则自动添加".bmp"
                if (HyStringUtility.IsStringEmpty(Path.GetExtension(animString)))
                {
                    animString += ".bmp";
                }
                strList.Add(animString);
            }
            else
            {
                string prefix = animString.Substring(0, pos);
                string fileex = Path.GetExtension(prefix);     //文件后缀
                prefix = Path.GetFileNameWithoutExtension(prefix);
                //如果文件不包含扩展名,则自动添加".bmp"
                if (HyStringUtility.IsStringEmpty(fileex))
                {
                    fileex = ".bmp";
                }

                string numbers = animString.Substring(pos + 1);

                string[] imgNumbers = numbers.Split('-');

                strList.Add(string.Format(@"{0}{1}{2}", prefix, imgNumbers[0], fileex));

                if (imgNumbers.Length > 1)
                {
                    for (int j = 0; j < imgNumbers[1].Length - 1; j++)
                    {
                        strList.Add(string.Format(@"{0}{1}{2}", prefix, imgNumbers[1][j], fileex));
                    }
                }
            }

            return(strList.ToArray());
        }
示例#3
0
        public static string SelectFolder(string CurrentPath)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.ShowNewFolderButton = true;
            dlg.RootFolder          = Environment.SpecialFolder.Desktop;
            if (!HyStringUtility.IsStringEmpty(CurrentPath))
            {
                dlg.SelectedPath = CurrentPath;
            }
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                return(dlg.SelectedPath);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        public static Font ParseFontString(string fontString)
        {
            if (HyStringUtility.IsStringEmpty(fontString))
            {
                return(DefaulFont.Clone() as Font);
            }

            try
            {
                string[] sections = fontString.Split('#');
                Font     font     = new Font(
                    new FontFamily(sections[0]),
                    float.Parse(sections[1]),
                    (FontStyle)(Enum.Parse(typeof(FontStyle), sections[3].Replace(':', ','), true)),
                    (GraphicsUnit)(Enum.Parse(typeof(GraphicsUnit), sections[2], true))
                    );
                return(font);
            }
            catch
            {
                return(DefaulFont.Clone() as Font);
            }
        }