forked from TansuoTro/MineRealmsUupdateSystem-Server
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddFileVersionForm.cs
More file actions
98 lines (89 loc) · 3.09 KB
/
AddFileVersionForm.cs
File metadata and controls
98 lines (89 loc) · 3.09 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using MRUS.Core;
namespace MRUS.Server
{
public partial class AddFileVersionForm : Form
{
public event ESBasic.CbGeneric addSuccessEvent;
private UpdateConfiguration fileConfig;
private bool isNew = true;
public AddFileVersionForm(UpdateConfiguration _fileConfig, FileUnit fileObject)
{
InitializeComponent();
this.fileConfig = _fileConfig;
DirectoryInfo dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "FileFolder\\");
List<string> files = ESBasic.Helpers.FileHelper.GetOffspringFiles(AppDomain.CurrentDomain.BaseDirectory + "FileFolder\\");
files.Sort();
this.comboBox1.DataSource = files;
if (fileObject != null)
{
this.isNew = false;
}
if (files.Count > 0)
{
this.comboBox1.SelectedIndex = 0;
}
if (!isNew)
{
this.comboBox1.Text = fileObject.FileRelativePath;
this.textBox_version.Text = fileObject.Version.ToString();
this.button1.Text = "修改";
this.comboBox1.Enabled = false;
this.Text = "修改";
}
}
private void button1_Click(object sender, EventArgs e)
{
FileUnit fileObject = new FileUnit();
fileObject.FileRelativePath = this.comboBox1.Text.Trim();
try
{
fileObject.Version = float.Parse(this.textBox_version.Text.Trim());
}
catch
{
MessageBox.Show("版本格式输入不正确,请输入小数!");
return;
}
if (this.isNew)
{
if (this.fileConfig.FileList.Contains(fileObject))
{
MessageBox.Show("该文件已经存在,不能重复添加");
return;
}
else
{
this.fileConfig.FileList.Add(fileObject);
this.fileConfig.Save();
this.addSuccessEvent();
this.Close();
}
}
else
{
foreach (FileUnit file in this.fileConfig.FileList)
{
if (file.FileRelativePath == this.comboBox1.Text.Trim())
{
file.Version = float.Parse(this.textBox_version.Text.Trim());
break;
}
}
this.fileConfig.Save();
this.addSuccessEvent();
this.Close();
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}