コード例 #1
0
        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);
        }
コード例 #2
0
        protected override void Execute()
        {
            var pathInfo        = new CustomViewPathInfo();
            var settingsService = new SettingsService(pathInfo);

            var viewModel = new SettingsViewModel(settingsService);
            var view      = new SettingsView {
                DataContext = viewModel
            };

            view.ShowDialog();
        }
コード例 #3
0
        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);
            }

            var importTips = new ImportTips {
                TipLanguages = tipLanguages
            };

            var count = usefulTipsService.AddUsefulTips(importTips, true);

            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.Added__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.Added__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_new_useful_tips_installed, PluginResources.Plugin_Name);
        }
コード例 #4
0
 public UsefulTipsService(TipsProvider tipsProvider, CustomViewPathInfo customViewPathInfo)
 {
     _tipsRoot           = new XmlRootAttribute("Tips");
     _tipsProvider       = tipsProvider;
     _customViewPathInfo = customViewPathInfo;
 }
コード例 #5
0
 public SettingsService(CustomViewPathInfo pathInfo)
 {
     _pathInfo = pathInfo;
 }