예제 #1
0
파일: TaskHelpers.cs 프로젝트: KoMiI/ShareX
        public static string GetImageFilename(TaskSettings taskSettings, Image image)
        {
            string filename;

            NameParser nameParser = new NameParser(NameParserType.FileName)
            {
                Picture             = image,
                AutoIncrementNumber = Program.Settings.NameParserAutoIncrementNumber,
                MaxNameLength       = taskSettings.AdvancedSettings.NamePatternMaxLength,
                MaxTitleLength      = taskSettings.AdvancedSettings.NamePatternMaxTitleLength,
                CustomTimeZone      = taskSettings.UploadSettings.UseCustomTimeZone ? taskSettings.UploadSettings.CustomTimeZone : null
            };

            ImageTag imageTag = image.Tag as ImageTag;

            if (imageTag != null)
            {
                nameParser.WindowText  = imageTag.ActiveWindowTitle;
                nameParser.ProcessName = imageTag.ActiveProcessName;
            }

            if (string.IsNullOrEmpty(nameParser.WindowText))
            {
                filename = nameParser.Parse(taskSettings.UploadSettings.NameFormatPattern) + ".bmp";
            }
            else
            {
                filename = nameParser.Parse(taskSettings.UploadSettings.NameFormatPatternActiveWindow) + ".bmp";
            }

            Program.Settings.NameParserAutoIncrementNumber = nameParser.AutoIncrementNumber;

            return(filename);
        }
예제 #2
0
        public static string GetImageFilename(TaskSettings taskSettings, Image image)
        {
            string filename;

            NameParser nameParser = new NameParser(NameParserType.FileName);

            nameParser.MaxNameLength       = 100;
            nameParser.Picture             = image;
            nameParser.AutoIncrementNumber = Program.Settings.NameParserAutoIncrementNumber;

            ImageTag imageTag = image.Tag as ImageTag;

            if (imageTag != null)
            {
                nameParser.WindowText = imageTag.ActiveWindowTitle;
            }

            if (string.IsNullOrEmpty(nameParser.WindowText))
            {
                filename = nameParser.Parse(taskSettings.UploadSettings.NameFormatPattern) + ".bmp";
            }
            else
            {
                filename = nameParser.Parse(taskSettings.UploadSettings.NameFormatPatternActiveWindow) + ".bmp";
            }

            Program.Settings.NameParserAutoIncrementNumber = nameParser.AutoIncrementNumber;

            return(filename);
        }
예제 #3
0
        public static string GetFilename(TaskSettings taskSettings, string extension = null, Image image = null)
        {
            string filename;

            NameParser nameParser = new NameParser(NameParserType.FileName)
            {
                AutoIncrementNumber = Program.Settings.NameParserAutoIncrementNumber,
                MaxNameLength       = taskSettings.AdvancedSettings.NamePatternMaxLength,
                MaxTitleLength      = taskSettings.AdvancedSettings.NamePatternMaxTitleLength,
                CustomTimeZone      = taskSettings.UploadSettings.UseCustomTimeZone ? taskSettings.UploadSettings.CustomTimeZone : null
            };

            if (image != null)
            {
                nameParser.ImageWidth  = image.Width;
                nameParser.ImageHeight = image.Height;

                ImageTag imageTag = image.Tag as ImageTag;

                if (imageTag != null)
                {
                    nameParser.WindowText  = imageTag.WindowTitle;
                    nameParser.ProcessName = imageTag.ProcessName;
                }
            }

            if (!string.IsNullOrEmpty(nameParser.WindowText))
            {
                filename = nameParser.Parse(taskSettings.UploadSettings.NameFormatPatternActiveWindow);
            }
            else
            {
                filename = nameParser.Parse(taskSettings.UploadSettings.NameFormatPattern);
            }

            Program.Settings.NameParserAutoIncrementNumber = nameParser.AutoIncrementNumber;

            if (!string.IsNullOrEmpty(extension))
            {
                filename += "." + extension.TrimStart('.');
            }

            return(filename);
        }