private void ExportSettings()
 {
     using (var dialog = new SaveFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_SaveGeneralSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <Rubberduck.Settings.GeneralSettings> {
             FilePath = dialog.FileName
         };
         service.Save(GetCurrentGeneralSettings());
         var hkService = new XmlPersistanceService <HotkeySettings> {
             FilePath = dialog.FileName
         };
         hkService.Save(new HotkeySettings {
             Settings = Hotkeys.ToArray()
         });
     }
 }
 private void ExportSettings()
 {
     using (var dialog = new SaveFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_SaveUnitTestSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <Rubberduck.Settings.UnitTestSettings> {
             FilePath = dialog.FileName
         };
         service.Save(new Rubberduck.Settings.UnitTestSettings
         {
             BindingMode = BindingMode,
             AssertMode  = AssertMode,
             ModuleInit  = ModuleInit,
             MethodInit  = MethodInit,
             DefaultTestStubInNewModule = DefaultTestStubInNewModule
         });
     }
 }
 private void ImportSettings()
 {
     using (var dialog = new OpenFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_LoadGeneralSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <Rubberduck.Settings.GeneralSettings> {
             FilePath = dialog.FileName
         };
         var general   = service.Load(new Rubberduck.Settings.GeneralSettings());
         var hkService = new XmlPersistanceService <HotkeySettings> {
             FilePath = dialog.FileName
         };
         var hotkey = hkService.Load(new HotkeySettings());
         //Always assume Smart Indenter registry import has been prompted if importing.
         general.SmartIndenterPrompted = true;
         TransferSettingsToView(general, hotkey);
     }
 }
Example #4
0
 private void ExportSettings()
 {
     using (var dialog = new SaveFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_SaveWindowSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <Rubberduck.Settings.WindowSettings> {
             FilePath = dialog.FileName
         };
         service.Save(new Rubberduck.Settings.WindowSettings()
         {
             CodeExplorerVisibleOnStartup    = CodeExplorerVisibleOnStartup,
             CodeInspectionsVisibleOnStartup = CodeInspectionsVisibleOnStartup,
             SourceControlVisibleOnStartup   = SourceControlVisibleOnStartup,
             TestExplorerVisibleOnStartup    = TestExplorerVisibleOnStartup,
             TodoExplorerVisibleOnStartup    = TodoExplorerVisibleOnStartup
         });
     }
 }
Example #5
0
 private void ExportSettings()
 {
     using (var dialog = new SaveFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_SaveIndenterSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <SmartIndenter.IndenterSettings> {
             FilePath = dialog.FileName
         };
         service.Save((SmartIndenter.IndenterSettings)GetCurrentSettings());
     }
 }
 private void ImportSettings()
 {
     using (var dialog = new OpenFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_LoadInspectionSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <CodeInspectionSettings> {
             FilePath = dialog.FileName
         };
         var loaded = service.Load(new CodeInspectionSettings());
         TransferSettingsToView(loaded);
     }
 }
Example #7
0
 private void ImportSettings()
 {
     using (var dialog = new OpenFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_LoadToDoSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <ToDoListSettings> {
             FilePath = dialog.FileName
         };
         var loaded = service.Load(new ToDoListSettings());
         TodoSettings = new ObservableCollection <ToDoMarker>(loaded.ToDoMarkers);
     }
 }
Example #8
0
 private void ExportSettings()
 {
     using (var dialog = new SaveFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_SaveToDoSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <ToDoListSettings> {
             FilePath = dialog.FileName
         };
         service.Save(new ToDoListSettings {
             ToDoMarkers = TodoSettings.Select(m => new ToDoMarker(m.Text.ToUpperInvariant())).Distinct().ToArray()
         });
     }
 }
Example #9
0
        // ReSharper disable InconsistentNaming
        public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
        {
            _kernel = new StandardKernel(new NinjectSettings {
                LoadExtensions = true
            }, new FuncModule(), new DynamicProxyModule());

            try
            {
                var currentDomain = AppDomain.CurrentDomain;
                currentDomain.AssemblyResolve += LoadFromSameFolder;

                var config = new XmlPersistanceService <GeneralSettings>
                {
                    FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Rubberduck",
                                            "rubberduck.config")
                };

                var settings = config.Load(null);
                if (settings != null)
                {
                    try
                    {
                        var cultureInfo = CultureInfo.GetCultureInfo(settings.Language.Code);
                        Dispatcher.CurrentDispatcher.Thread.CurrentUICulture = cultureInfo;
                    }
                    catch (CultureNotFoundException) { }
                }

                _kernel.Load(new RubberduckModule((VBE)Application, (AddIn)AddInInst));
                _app = _kernel.Get <App>();
                _app.Startup();
            }
            catch (Exception exception)
            {
                _logger.Fatal(exception);
                System.Windows.Forms.MessageBox.Show(exception.ToString(), RubberduckUI.RubberduckLoadFailure, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void ExportSettings()
 {
     using (var dialog = new SaveFileDialog
     {
         Filter = SettingsUI.DialogMask_XmlFilesOnly,
         Title = SettingsUI.DialogCaption_SaveAutocompletionSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <Rubberduck.Settings.AutoCompleteSettings> {
             FilePath = dialog.FileName
         };
         service.Save(new Rubberduck.Settings.AutoCompleteSettings
         {
             IsEnabled       = IsEnabled,
             BlockCompletion = new Rubberduck.Settings.AutoCompleteSettings.BlockCompletionSettings
             {
                 CompleteOnEnter = CompleteBlockOnEnter,
                 CompleteOnTab   = CompleteBlockOnTab,
                 IsEnabled       = EnableBlockCompletion
             },
             SelfClosingPairs = new Rubberduck.Settings.AutoCompleteSettings.SelfClosingPairSettings
             {
                 IsEnabled = EnableSelfClosingPairs
             },
             SmartConcat = new Rubberduck.Settings.AutoCompleteSettings.SmartConcatSettings
             {
                 ConcatVbNewLineModifier =
                     ConcatVbNewLine ? ModifierKeySetting.CtrlKey : ModifierKeySetting.None,
                 IsEnabled = EnableSmartConcat
             }
         });
     }
 }
Example #11
0
 private void ExportSettings()
 {
     using (var dialog = new SaveFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_SaveInspectionSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <Rubberduck.Settings.AutoCompleteSettings> {
             FilePath = dialog.FileName
         };
         service.Save(new Rubberduck.Settings.AutoCompleteSettings
         {
             CompleteBlockOnTab = this.CompleteBlockOnTab,
             AutoCompletes      = new HashSet <AutoCompleteSetting>(Settings),
         });
     }
 }
 private void ExportSettings()
 {
     using (var dialog = new SaveFileDialog
     {
         Filter = RubberduckUI.DialogMask_XmlFilesOnly,
         Title = RubberduckUI.DialogCaption_SaveInspectionSettings
     })
     {
         dialog.ShowDialog();
         if (string.IsNullOrEmpty(dialog.FileName))
         {
             return;
         }
         var service = new XmlPersistanceService <CodeInspectionSettings> {
             FilePath = dialog.FileName
         };
         service.Save(new CodeInspectionSettings
         {
             CodeInspections                 = new HashSet <CodeInspectionSetting>(InspectionSettings.SourceCollection.OfType <CodeInspectionSetting>()),
             WhitelistedIdentifiers          = WhitelistedIdentifierSettings.Distinct().ToArray(),
             RunInspectionsOnSuccessfulParse = _runInspectionsOnSuccessfulParse
         });
     }
 }
Example #13
0
        private void InitializeAddIn()
        {
            Splash splash = null;

            try
            {
                if (_isInitialized)
                {
                    // The add-in is already initialized. See:
                    // The strange case of the add-in initialized twice
                    // http://msmvps.com/blogs/carlosq/archive/2013/02/14/the-strange-case-of-the-add-in-initialized-twice.aspx
                    return;
                }

                var configLoader = new XmlPersistanceService <GeneralSettings>
                {
                    FilePath =
                        Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                     "Rubberduck", "rubberduck.config")
                };
                var configProvider = new GeneralConfigProvider(configLoader);

                _initialSettings = configProvider.Create();
                if (_initialSettings != null)
                {
                    try
                    {
                        var cultureInfo = CultureInfo.GetCultureInfo(_initialSettings.Language.Code);
                        Dispatcher.CurrentDispatcher.Thread.CurrentUICulture = cultureInfo;
                    }
                    catch (CultureNotFoundException)
                    {
                    }

                    try
                    {
                        if (_initialSettings.SetDpiUnaware)
                        {
                            SHCore.SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_DPI_Unaware);
                        }
                    }
                    catch (Exception)
                    {
                        Debug.Assert(false, "Could not set DPI awareness.");
                    }
                }
                else
                {
                    Debug.Assert(false, "Settings could not be initialized.");
                }

                if (_initialSettings?.CanShowSplash ?? false)
                {
                    splash = new Splash
                    {
                        // note: IVersionCheck.CurrentVersion could return this string.
                        Version = $"version {Assembly.GetExecutingAssembly().GetName().Version}"
                    };
                    splash.Show();
                    splash.Refresh();
                }

                Startup();
            }
            catch (Win32Exception)
            {
                System.Windows.Forms.MessageBox.Show(Resources.RubberduckUI.RubberduckReloadFailure_Message,
                                                     RubberduckUI.RubberduckReloadFailure_Title,
                                                     MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception exception)
            {
                _logger.Fatal(exception);
                System.Windows.Forms.MessageBox.Show(
#if DEBUG
                    exception.ToString(),
#else
                    exception.Message.ToString(),
#endif
                    RubberduckUI.RubberduckLoadFailure, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                splash?.Dispose();
            }
        }