mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-29 17:02:05 +13:00
If service links are not changed then reset them to default
This commit is contained in:
parent
53ed4fb34d
commit
82ffe63f45
2 changed files with 18 additions and 1 deletions
|
@ -83,7 +83,12 @@ public OCRForm(Bitmap bmp, OCROptions options)
|
|||
|
||||
nudScaleFactor.SetValue((decimal)Options.ScaleFactor);
|
||||
|
||||
if (Options.ServiceLinks != null && Options.ServiceLinks.Count > 0)
|
||||
if (Options.ServiceLinks == null || Options.IsDefaultServiceLinks())
|
||||
{
|
||||
Options.ServiceLinks = OCROptions.DefaultServiceLinks;
|
||||
}
|
||||
|
||||
if (Options.ServiceLinks.Count > 0)
|
||||
{
|
||||
cbServices.Items.AddRange(Options.ServiceLinks.ToArray());
|
||||
cbServices.SelectedIndex = Options.SelectedServiceLink;
|
||||
|
|
|
@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
|
|||
#endregion License Information (GPL v3)
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
|
@ -36,6 +37,17 @@ public class OCROptions
|
|||
public List<ServiceLink> ServiceLinks { get; set; } = DefaultServiceLinks;
|
||||
public int SelectedServiceLink { get; set; } = 0;
|
||||
|
||||
public bool IsDefaultServiceLinks()
|
||||
{
|
||||
if (ServiceLinks != null && ServiceLinks.Count > 0)
|
||||
{
|
||||
List<ServiceLink> defaultServiceLinks = DefaultServiceLinks;
|
||||
return ServiceLinks.All(x => defaultServiceLinks.Any(y => x.Name == y.Name));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<ServiceLink> DefaultServiceLinks => new List<ServiceLink>()
|
||||
{
|
||||
new ServiceLink("Google Translate", "https://translate.google.com/?sl=auto&tl=en&text={0}&op=translate"),
|
||||
|
|
Loading…
Reference in a new issue