mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 04:33:04 +01:00
Improve translate-no-internet-connection error - thx PM :)
This commit is contained in:
parent
f926305499
commit
c703bcaa68
@ -815,6 +815,7 @@ Note: Do check free disk space.</WaveFileMalformed>
|
||||
<Preset>Preset</Preset>
|
||||
<Crf>CRF</Crf>
|
||||
<TuneFor>Tune for</TuneFor>
|
||||
<AlignRight>Align right</AlignRight>
|
||||
</GenerateVideoWithBurnedInSubs>
|
||||
<GetDictionaries>
|
||||
<Title>Need dictionaries?</Title>
|
||||
|
@ -9,6 +9,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@ -313,6 +314,21 @@ namespace Nikse.SubtitleEdit.Forms.Translate
|
||||
Translate();
|
||||
}
|
||||
|
||||
public static bool IsAvailableNetworkActive()
|
||||
{
|
||||
if (NetworkInterface.GetIsNetworkAvailable())
|
||||
{
|
||||
var interfaces = NetworkInterface.GetAllNetworkInterfaces();
|
||||
return (from face in interfaces
|
||||
where face.OperationalStatus == OperationalStatus.Up
|
||||
where (face.NetworkInterfaceType != NetworkInterfaceType.Tunnel) && (face.NetworkInterfaceType != NetworkInterfaceType.Loopback)
|
||||
select face.GetIPv4Statistics()).Any(statistics => (statistics.BytesReceived > 0) && (statistics.BytesSent > 0));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void Translate()
|
||||
{
|
||||
var translator = (ITranslationProcessor)comboBoxParagraphHandling.SelectedItem;
|
||||
@ -340,7 +356,7 @@ namespace Nikse.SubtitleEdit.Forms.Translate
|
||||
}
|
||||
catch (TranslationException translationException)
|
||||
{
|
||||
if (translationException.InnerException != null && translationException.InnerException.Message.Contains("The remote name could not be resolved"))
|
||||
if (translationException.InnerException != null && !IsAvailableNetworkActive())
|
||||
{
|
||||
ShowNetworkError(translationException.InnerException);
|
||||
}
|
||||
|
@ -2170,6 +2170,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "GenerateVideoWithBurnedInSubs/TuneFor":
|
||||
language.GenerateVideoWithBurnedInSubs.TuneFor = reader.Value;
|
||||
break;
|
||||
case "GenerateVideoWithBurnedInSubs/AlignRight":
|
||||
language.GenerateVideoWithBurnedInSubs.AlignRight = reader.Value;
|
||||
break;
|
||||
case "GetDictionaries/Title":
|
||||
language.GetDictionaries.Title = reader.Value;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user