yangyin
2025-01-13 36616eb44dc36a4e6e3e7a7540310cb850218ea9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text; 
 
namespace DPumpHydr.WinFrmUI.Volute
{
    public class GlobalResource
    {
        public static string  ResourcesPath = @"Data\MainForm\Icons";
        public static string  tipTrailingIcon = "alert-square-rounded.png";//输入框前缀 标必须图片
        public static string  tipLeadingIcon = "north-star.png";//输入框后缀 标警告图片
 
        /// <summary>
        /// 输入框前缀 标必须图标
        /// </summary>
        /// <returns></returns>
        public static System.Drawing.Image GetTipTrailingIcon()
        {
            System.Drawing.Image image = null;
            if (tipTrailingIcon != null)
            {
                image = Properties.Resources.TipRed22;//  GlobalResource.BuildImage(tipTrailingIcon);
            }
            return image;
        }
        
        /// <summary>
        /// 输入框后缀 标警告图标
        /// </summary>
        /// <returns></returns>
        public static System.Drawing.Image GetLeadingIcon()
        {
            System.Drawing.Image image = null;
            if (tipLeadingIcon != null)
            {
                image = Properties.Resources.Need16;// GlobalResource.BuildImage(tipLeadingIcon);
            }
            return image;
        }
 
        /// <summary>
        /// 指定大小图片
        /// </summary>
        /// <param name="path">文件夹路径(编译路径下的)</param>
        /// <param name="filename">文件名</param>
        /// <returns></returns>
        public static System.Drawing.Image BuildImage( string filename,int widthsize ,int heightsize )
        {
            var image = BuildImage(filename);
            if (image == null)
                return null;
            if (widthsize > 0 && heightsize > 0)
            {
                System.Drawing.Image thumbnail = image.GetThumbnailImage(widthsize, heightsize, () => false, IntPtr.Zero);
                return thumbnail;
            }
            else
            {
                return image;
            }
        }
 
        /// <summary>
        /// 原大小图片
        /// </summary>
        /// <param name="path">路径</param>
        /// <param name="filename">文件名</param>
        /// <returns></returns>
        public static System.Drawing.Image BuildImage( string filename)
        {
            if (  filename == null)
            {
                return null;
            }
            string fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ResourcesPath, filename);
            if (File.Exists(fullPath))
            {
                System.Drawing.Image image = System.Drawing.Image.FromFile(fullPath);
                return image;
            }
            else
            {
                return null;
            }
        }
    }
}