Skip to content

Commit

Permalink
修复更新日志版本问题
Browse files Browse the repository at this point in the history
增加关于端口被占用的错误提示
修改相关提示
  • Loading branch information
Guailoudou committed May 28, 2024
1 parent a531ecd commit 76c025c
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 24 deletions.
20 changes: 20 additions & 0 deletions WpfApp1/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,25 @@
</Setter.Value>
</Setter>
</Style>

<!--<Style TargetType="ScrollViewer">
<Setter Property="OverridesDefaultStyle" Value="False" />
--><!--<Setter Property="CanContentScroll" Value="True" />-->
<!--<Setter Property="PanningMode" Value="VerticalFirst" />--><!--
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollViewer">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ScrollContentPresenter CanHorizontallyScroll="True" CanVerticallyScroll="True" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>-->
</Application.Resources>
</Application>
55 changes: 36 additions & 19 deletions WpfApp1/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,25 +393,25 @@ public void Relist() //刷新列表


}
private ControlTemplate CreateButtonTemplate()
{
ControlTemplate template = new ControlTemplate(typeof(Button));
FrameworkElementFactory borderFactory = new FrameworkElementFactory(typeof(Border));
borderFactory.SetValue(Border.BorderBrushProperty, new TemplateBindingExtension(BorderBrushProperty));
borderFactory.SetValue(Border.BorderThicknessProperty, new TemplateBindingExtension(BorderThicknessProperty));
borderFactory.SetValue(Border.CornerRadiusProperty, new CornerRadius(5));
//borderFactory.SetValue(Border.BackgroundProperty, new SolidColorBrush(Color.FromArgb(80, 221, 221, 221))); // 注意这里的背景色需要重新定义或引用

FrameworkElementFactory contentPresenterFactory = new FrameworkElementFactory(typeof(ContentPresenter));
contentPresenterFactory.SetBinding(ContentPresenter.ContentProperty, new Binding { Path = new PropertyPath("Content"), RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) });
contentPresenterFactory.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center);
contentPresenterFactory.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center);

borderFactory.AppendChild(contentPresenterFactory);
template.VisualTree = borderFactory;

return template;
}
//private ControlTemplate CreateButtonTemplate()
//{
// ControlTemplate template = new ControlTemplate(typeof(Button));
// FrameworkElementFactory borderFactory = new FrameworkElementFactory(typeof(Border));
// borderFactory.SetValue(Border.BorderBrushProperty, new TemplateBindingExtension(BorderBrushProperty));
// borderFactory.SetValue(Border.BorderThicknessProperty, new TemplateBindingExtension(BorderThicknessProperty));
// borderFactory.SetValue(Border.CornerRadiusProperty, new CornerRadius(5));
// //borderFactory.SetValue(Border.BackgroundProperty, new SolidColorBrush(Color.FromArgb(80, 221, 221, 221))); // 注意这里的背景色需要重新定义或引用

// FrameworkElementFactory contentPresenterFactory = new FrameworkElementFactory(typeof(ContentPresenter));
// contentPresenterFactory.SetBinding(ContentPresenter.ContentProperty, new Binding { Path = new PropertyPath("Content"), RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) });
// contentPresenterFactory.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center);
// contentPresenterFactory.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center);

// borderFactory.AppendChild(contentPresenterFactory);
// template.VisualTree = borderFactory;

// return template;
//}
private string Getversion() //获取文件版本号
{
Assembly assembly = Assembly.GetExecutingAssembly();
Expand Down Expand Up @@ -520,9 +520,26 @@ public void Checkopen(string m)
{
Logger.Log("[错误]请检查是否连接网络,或是程序是否拥有网络访问权限!");
//if (process != null && !process.HasExited)
state.Clear();
Relist();
Strapp();

}
if(m.Contains("Only one usage of each socket address"))
{
string pattern = @"(tcp|udp)\s*:\s*(\d+)";
Match match = Regex.Match(m, pattern);

if (match.Success)
{
// 提取并输出匹配到的协议和端口号
string protocol = match.Groups[1].Value;
string port = match.Groups[2].Value;
Logger.Log($"[错误]: 本地端口{protocol}:{port}被占用,请更换相关本地端口");
MessageBox.Show($"本地端口{protocol}:{port}被占用,请更换相关本地端口!!", "错误");
Strapp();
}
}
if (m.Contains("no such host"))
{
Logger.Log("[错误]请检查DNS是否正确,是否连接网络,或是程序是否拥有网络访问权限!");
Expand Down
4 changes: 3 additions & 1 deletion WpfApp1/OPL WpfApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>D:\WPFpublish\</PublishUrl>
<PublishUrl>D:\web\gitfileurl\urlfile\file\pack\</PublishUrl>
<Install>false</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
Expand All @@ -26,6 +26,8 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<UpdateUrl>https://file.gldhn.top/file/pack/</UpdateUrl>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>1.0.1.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
Expand Down
2 changes: 1 addition & 1 deletion WpfApp1/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.1.13")]
[assembly: AssemblyFileVersion("1.0.1.14")]
[assembly: NeutralResourcesLanguage("zh-CN")]
2 changes: 1 addition & 1 deletion WpfApp1/cs/Heart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void SendKeepAliveMessage()
try
{
_client.Send(buffer);
}catch (SocketException se)
}catch (SocketException)
{
//Logger.Log(se.Message);
//break;
Expand Down
7 changes: 6 additions & 1 deletion WpfApp1/cs/json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ public void getjosn() //读取配置
string ujson = JsonConvert.SerializeObject(config, Formatting.Indented);
wejson(ujson);
}

if(config.LogLevel != Ologv)
{
config.LogLevel = Ologv;
string ujson = JsonConvert.SerializeObject(config, Formatting.Indented);
wejson(ujson);
}

}
catch (JsonException je)
Expand Down
2 changes: 1 addition & 1 deletion WpfApp1/cs/net.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class Net
{
public async Task GetPreset()
{
int pvn = 14;//协议版本号
int pvn = 15;//协议版本号
Logger.Log("[执行]网络请求文件preset.json");
string fileurl = "https://file.gldhn.top/file/json/preset.json";
HttpClient httpClient = new HttpClient();
Expand Down

0 comments on commit 76c025c

Please sign in to comment.