コード例 #1
0
        public void TestProxyPassword1()
        {
            var settings = new ApplicationSettings("foo");
            var model    = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            var changes = new List <string>();

            model.PropertyChanged += (sender, args) => changes.Add(args.PropertyName);

            model.ProxyPassword = "******";
            changes.Should().Equal(new object[] { "ProxyPassword" });

            model.ProxyPassword = "******";
            changes.Should().Equal(new object[]
            {
                "ProxyPassword",
                "ProxyPassword"
            });

            model.ProxyPassword = "******";
            changes.Should().Equal(new object[]
            {
                "ProxyPassword",
                "ProxyPassword"
            });
        }
コード例 #2
0
        public void TestSetFolderDataSourcePatternsSkipLeadingSpace()
        {
            var settings = new ApplicationSettings("foo");
            var model    = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            model.FolderDataSourcePatterns = " *.log";
            settings.DataSources.FolderDataSourcePattern.Should().Be(" *.log");
        }
コード例 #3
0
        public void TestSetFolderDataSourcePatterns1([Values(null, "", " ", ";;")] string emptyPattern)
        {
            var settings = new ApplicationSettings("foo");
            var model    = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            model.FolderDataSourcePatterns = emptyPattern;
            settings.DataSources.FolderDataSourcePattern.Should().Be(emptyPattern);
        }
コード例 #4
0
        public void TestSetFolderDataSourceMultiplePatterns()
        {
            var settings = new ApplicationSettings("foo");
            var model    = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            model.FolderDataSourcePatterns = "*.txt;*.log ;*log*";
            settings.DataSources.FolderDataSourcePattern.Should().Be("*.txt;*.log ;*log*");
        }
コード例 #5
0
        public void TestChangeDataContext()
        {
            _settings.Object.ProxyPassword = "******";
            var dataContext = new SettingsFlyoutViewModel(_applicationSettings.Object, new ServiceContainer());

            _control.DataContext = dataContext;

            new Action(() => _control.DataContext = null).Should().NotThrow();
        }
コード例 #6
0
        public void TestConstruction2([ValueSource(nameof(Encodings))] Encoding encoding)
        {
            var settings = new ApplicationSettings("foo");

            settings.LogFile.DefaultEncoding = encoding;

            var model = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            model.DefaultTextFileEncoding.Should().NotBeNull();
            model.DefaultTextFileEncoding.Encoding.Should().BeSameAs(encoding);
        }
コード例 #7
0
        public void TestConstruction1([Values(true, false)] bool recursive)
        {
            var settings = new ApplicationSettings("foo");

            settings.DataSources.FolderDataSourceRecursive = recursive;
            settings.DataSources.FolderDataSourcePattern   = "*.log;*.txt";

            var model = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            model.FolderDataSourceRecursive.Should().Be(recursive);
            model.FolderDataSourcePatterns.Should().Be("*.log;*.txt");
        }
コード例 #8
0
        public void TestTestChangeDefaultEncoding()
        {
            var settings = new ApplicationSettings("foo");
            var model    = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            var newEncoding = model.TextFileEncodings.Last();

            model.DefaultTextFileEncoding = newEncoding;
            settings.LogFile.DefaultEncoding.Should().Be(newEncoding.Encoding);

            newEncoding = model.TextFileEncodings.First();
            model.DefaultTextFileEncoding = newEncoding;
            settings.LogFile.DefaultEncoding.Should().Be(newEncoding.Encoding);
        }
コード例 #9
0
        public void TestProxyPassword2()
        {
            var settings = new ApplicationSettings("foo");
            var model    = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            model.ProxyPassword = "******";
            settings.AutoUpdate.ProxyPassword.Should().Be("foobar");

            model.ProxyPassword = null;
            settings.AutoUpdate.ProxyPassword.Should().BeNull();

            model.ProxyPassword = string.Empty;
            settings.AutoUpdate.ProxyPassword.Should().BeEmpty();
        }
コード例 #10
0
        public MainWindowViewModel(IServiceContainer services,
                                   IApplicationSettings settings,
                                   DataSources dataSources,
                                   QuickFilters quickFilters,
                                   IActionCenter actionCenter,
                                   IAutoUpdater updater)
        {
            if (dataSources == null)
            {
                throw new ArgumentNullException(nameof(dataSources));
            }
            if (quickFilters == null)
            {
                throw new ArgumentNullException(nameof(quickFilters));
            }
            if (updater == null)
            {
                throw new ArgumentNullException(nameof(updater));
            }

            var services1           = services;
            var applicationSettings = settings;

            _plugins = new PluginsMainPanelViewModel(applicationSettings,
                                                     services1.Retrieve <IDispatcher>(),
                                                     services1.Retrieve <IPluginUpdater>(),
                                                     services1.Retrieve <IPluginLoader>().Plugins);
            _settings = new SettingsFlyoutViewModel(settings, services);
            _actionCenterViewModel = new ActionCenterViewModel(services.Retrieve <IDispatcher>(), actionCenter);

            _logViewPanel = new LogViewMainPanelViewModel(services,
                                                          actionCenter,
                                                          dataSources,
                                                          quickFilters,
                                                          services.Retrieve <IHighlighters>(),
                                                          applicationSettings);
            WindowTitle       = _logViewPanel.WindowTitle;
            WindowTitleSuffix = _logViewPanel.WindowTitleSuffix;

            ((NavigationService)services.Retrieve <INavigationService>()).LogViewer = _logViewPanel;

            _logViewPanel.PropertyChanged += LogViewPanelOnPropertyChanged;

            var timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(100)
            };

            timer.Tick += TimerOnTick;
            timer.Start();

            _autoUpdater = new AutoUpdateViewModel(updater, settings.AutoUpdate, services.Retrieve <IDispatcher>());

            var fileMenuViewModel = new FileMenuViewModel(new DelegateCommand2(AddDataSourceFromFile),
                                                          new DelegateCommand2(AddDataSourceFromFolder),
                                                          _logViewPanel.DataSources.RemoveCurrentDataSourceCommand,
                                                          _logViewPanel.DataSources.RemoveAllDataSourcesCommand,
                                                          new DelegateCommand2(ShowPlugins),
                                                          new DelegateCommand2(ShowSettings),
                                                          new DelegateCommand2(Exit));
            var editMenu = new EditMenuViewModel(new DelegateCommand2(ShowGoToLine),
                                                 new DelegateCommand2(ShowGoToDataSource),
                                                 new DelegateCommand2(GoToNextDataSource),
                                                 new DelegateCommand2(GoToPreviousDataSource),
                                                 _logViewPanel);
            var viewMenu = new ViewMenuViewModel();
            var helpMenu = new HelpMenuViewModel(new DelegateCommand2(ReportIssue),
                                                 new DelegateCommand2(SuggestFeature),
                                                 new DelegateCommand2(AskQuestion),
                                                 AutoUpdater.CheckForUpdatesCommand,
                                                 new DelegateCommand(ShowLog),
                                                 new DelegateCommand2(ShowAboutFlyout));

            _mainMenu = new MainMenu(fileMenuViewModel,
                                     editMenu,
                                     viewMenu,
                                     helpMenu);
            _mainMenu.CurrentDataSource = _logViewPanel.CurrentDataSource;
        }
コード例 #11
0
 public static void SetControls(SettingsFlyoutViewModel columnViewModel)
 {
     CheckDesignMode();
 }