mirror of
https://github.com/netchx/netch.git
synced 2026-03-26 18:49:46 +08:00
refactor: SubscribeForm Save
- remove: duplicate link check - fix: check remark duplicate not work
This commit is contained in:
7
Netch/Forms/SubscribeForm.Designer.cs
generated
7
Netch/Forms/SubscribeForm.Designer.cs
generated
@@ -81,11 +81,11 @@
|
||||
//
|
||||
// ClearButton
|
||||
//
|
||||
this.ClearButton.Location = new System.Drawing.Point(477, 103);
|
||||
this.ClearButton.Location = new System.Drawing.Point(448, 103);
|
||||
this.ClearButton.Name = "ClearButton";
|
||||
this.ClearButton.Size = new System.Drawing.Size(58, 26);
|
||||
this.ClearButton.Size = new System.Drawing.Size(87, 26);
|
||||
this.ClearButton.TabIndex = 7;
|
||||
this.ClearButton.Text = "Clear";
|
||||
this.ClearButton.Text = "Unselect";
|
||||
this.ClearButton.UseVisualStyleBackColor = true;
|
||||
this.ClearButton.Click += new System.EventHandler(this.ClearButton_Click);
|
||||
//
|
||||
@@ -114,7 +114,6 @@
|
||||
this.LinkTextBox.Name = "LinkTextBox";
|
||||
this.LinkTextBox.Size = new System.Drawing.Size(545, 23);
|
||||
this.LinkTextBox.TabIndex = 4;
|
||||
this.LinkTextBox.TextChanged += new System.EventHandler(this.ListTextBox_TextChanged);
|
||||
//
|
||||
// LinkLabel
|
||||
//
|
||||
|
||||
@@ -109,39 +109,23 @@ namespace Netch.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
// 备注重复的订阅项
|
||||
var duplicateRemarkItems = Global.Settings.SubscribeLink.Where(link => link.Remark.Equals(RemarkLabel.Text));
|
||||
|
||||
// 链接重复的订阅项
|
||||
SubscribeLink duplicateLinkItem = null;
|
||||
try
|
||||
{
|
||||
duplicateLinkItem = Global.Settings.SubscribeLink.First(link => link.Link.Equals(LinkTextBox.Text));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (duplicateRemarkItems.Any())
|
||||
if (Global.Settings.SubscribeLink.Any(link => link.Remark.Equals(RemarkTextBox.Text)))
|
||||
{
|
||||
MessageBoxX.Show("Remark Name Duplicate!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (duplicateLinkItem != null)
|
||||
if (_editingIndex == -1)
|
||||
{
|
||||
if (duplicateLinkItem.Remark != RemarkTextBox.Text)
|
||||
Global.Settings.SubscribeLink.Add(new SubscribeLink
|
||||
{
|
||||
RenameServersGroup(duplicateLinkItem.Remark, RemarkTextBox.Text);
|
||||
}
|
||||
|
||||
duplicateLinkItem.Remark = RemarkTextBox.Text;
|
||||
duplicateLinkItem.UserAgent = UserAgentTextBox.Text;
|
||||
Remark = RemarkTextBox.Text,
|
||||
Link = LinkTextBox.Text,
|
||||
UserAgent = UserAgentTextBox.Text
|
||||
});
|
||||
}
|
||||
else if (_editingIndex != -1)
|
||||
else
|
||||
{
|
||||
// 只修改备注/未修改被上面处理
|
||||
var target = Global.Settings.SubscribeLink[_editingIndex];
|
||||
if (MessageBox.Show(i18N.Translate("Delete the corresponding group of items in the server list?"), i18N.Translate("Confirm"), MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
@@ -156,15 +140,6 @@ namespace Netch.Forms
|
||||
target.Remark = RemarkTextBox.Text;
|
||||
target.UserAgent = UserAgentTextBox.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Settings.SubscribeLink.Add(new SubscribeLink
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Link = LinkTextBox.Text,
|
||||
UserAgent = UserAgentTextBox.Text
|
||||
});
|
||||
}
|
||||
|
||||
Configuration.Save();
|
||||
Global.Settings.UseProxyToUpdateSubscription = UseSelectedServerCheckBox.Checked;
|
||||
@@ -260,17 +235,5 @@ namespace Netch.Forms
|
||||
{
|
||||
ResetEditingGroup();
|
||||
}
|
||||
|
||||
private void ListTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
for (var i = 0; i < SubscribeLinkListView.Items.Count; i++)
|
||||
{
|
||||
if (((TextBox) sender).Text == SubscribeLinkListView.Items[i].SubItems[1].Text)
|
||||
{
|
||||
_editingIndex = i;
|
||||
AddSubscriptionBox.Text = SubscribeLinkListView.Items[i].SubItems[0].Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user