tangxu
2024-02-27 707a73304e0406b865548645c7cd1880a3651cc4
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI
{
    internal partial class ShowFileResultFrm : Form
    {
        private string _strFile;
        public string StrFile
        {
            get { return _strFile; }
            set { _strFile = value; }
        }
        /* Model.eLocalizationType _locationType = eLocalizationType.zhCN;
         public eLocalizationType LocationType
         {
             get { return _locationType; }
             set { _locationType = value; }
         }
 */
 
        public ShowFileResultFrm()
        {
            InitializeComponent();
        }
 
        public string InfoLabel
        {
            set { this.label1.Text = value + ",请问是否打开文件?"; }
        }
 
        private void ShowFileResultFrm_Load(object sender, EventArgs e)
        {
            /* if (_locationType == eLocalizationType.enUS)
             {
                 label1.Text = "Do you open the file?";
                 button1.Text = "Open Folder";
                 button2.Text = "Open File";
                 button3.Text = "Cancel";
             }
             else if (_locationType == eLocalizationType.ru)
             {
                 label1.Text = "ли  открыть ?";
                 button1.Text = "открыть папку";
                 button2.Text = "открыть файл";
                 button3.Text = "отменить";
 
                 button1.Width = 100;
                 button2.Width = 100;
                 button3.Width = 100;
             }*/
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string strFolder = System.IO.Path.GetDirectoryName(_strFile);
                System.Diagnostics.Process.Start(strFolder);
            }
            catch (Exception)
            {
                XtraMessageBox.Show("此文件夹无法打开", "打开文件错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            this.Close();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process.Start(_strFile);
            }
            catch (Exception)
            {
                XtraMessageBox.Show("此文件无法打开", "打开文件错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            this.Close();
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
 
    public class FileMessageBox
    {
        public FileMessageBox()
        {
 
        }
        public static void Show(string strFile)
        {
            ShowFileResultFrm frm = new ShowFileResultFrm();
            //frm.LocationType = eLocalizationType.zhCN;
            frm.StrFile = strFile;
            frm.ShowDialog();
        }
 
        //public static void Show(string strFile,eLocalizationType locationType)
        //{ 
        //    ShowFileResultFrm frm = new ShowFileResultFrm();
        //    //frm.LocationType = locationType;
        //    frm.StrFile = strFile;
        //    frm.ShowDialog();
        //}
    }
}