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"
            });
        }
        public void TestSetFolderDataSourcePatternsSkipLeadingSpace()
        {
            var settings = new ApplicationSettings("foo");
            var model    = new SettingsFlyoutViewModel(settings, new ServiceContainer());

            model.FolderDataSourcePatterns = " *.log";
            settings.DataSources.FolderDataSourcePattern.Should().Be(" *.log");
        }
        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);
        }
        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*");
        }
        public void TestChangeDataContext()
        {
            _settings.Object.ProxyPassword = "******";
            var dataContext = new SettingsFlyoutViewModel(_applicationSettings.Object, new ServiceContainer());

            _control.DataContext = dataContext;

            new Action(() => _control.DataContext = null).Should().NotThrow();
        }
        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);
        }
        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");
        }
        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);
        }
        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();
        }
        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;
        }
 public static void SetControls(SettingsFlyoutViewModel columnViewModel)
 {
     CheckDesignMode();
 }