protected override void Execute()
        {
            var customViewPathInfo = new CustomViewPathInfo();
            var pathInfo           = new PathInfo(PluginResources.Plugin_Name, "16");
            var tipsProvider       = new TipsProvider(pathInfo);
            var usefulTipsService  = new UsefulTipsService(tipsProvider, customViewPathInfo);

            var tipLanguages = usefulTipsService.GetPluginUsefulTips();

            if (tipLanguages.Count == 0)
            {
                MessageBox.Show(PluginResources.No_useful_tips_found, PluginResources.Plugin_Name);
            }

            AlignLanguageTipIds(tipLanguages, tipsProvider, usefulTipsService);

            var tipReferences = new List <TipReference>();

            foreach (var tipLanguage in tipLanguages)
            {
                tipReferences.Add(new TipReference
                {
                    LanguageId = tipLanguage.LanguageId,
                    Resources  = tipLanguage.Resources.Select(a => a.RelativePath).ToList(),
                    TipIds     = tipLanguage.Tips.Where(a => !string.IsNullOrEmpty(a.Id)).Select(a => a.Id).ToList()
                });
            }

            var removeTips = new RemoveTips {
                TipReferences = tipReferences
            };

            var count = usefulTipsService.RemoveUsefulTips(removeTips);

            if (count > 0)
            {
                //Option (1)
                // Use this if you have a reference to "using Sdl.Desktop.Platform" and comment out Option (2)
                //var message = string.Format(PluginResources.Removed__0__useful_tips, count);
                //message += Environment.NewLine + Environment.NewLine;
                //message += PluginResources.Restart_Trados_Studio_to_apply_changes;

                //var dr = MessageBox.Show(message, PluginResources.Plugin_Name, MessageBoxButton.YesNo, MessageBoxImage.Question);
                //if (dr == MessageBoxResult.Yes)
                //{
                //	StudioPlatform.Studio.Restart();
                //}

                //Option (2)
                // Use this if you DO NOT have a reference to "using Sdl.Desktop.Platform" and comment out Option (1)
                var message = string.Format(PluginResources.Removed__0__useful_tips, count);
                message += Environment.NewLine + Environment.NewLine;
                message += PluginResources.Restart_Trados_Studio_before_changes_are_applied;

                MessageBox.Show(message, PluginResources.Plugin_Name, MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            MessageBox.Show(PluginResources.No_useful_tips_removed, PluginResources.Plugin_Name);
        }
Beispiel #2
0
 public int RemoveUsefulTips(RemoveTips removeContext)
 {
     return(_tipsProvider.RemoveTips(removeContext));
 }