private void SearchInPDFButton_Click(object sender, EventArgs e)
        {
            //This will look through all the pdfs in the list and search for a keyword
            // then spit out a list of the pdfs and pages they were found
            List <string> filesIncludingSearch = new List <string>();

            try
            {
                for (int i = 0; i < FileList.Items.Count; i++)
                {
                    var         filePath    = FileList.Items[i].Text;
                    PdfDocument pdfDocument = new PdfDocument(filePath);
                    for (int j = 0; j < pdfDocument.Pages.Count; j++)
                    {
                        PdfPage pdfPage = pdfDocument.Pages[j];
                        //string content;
                        string pdfText   = pdfPage.ToString();
                        var    pdfToText = new PdfToText();
                        pdfToText.Load(filePath);
                        var content = pdfToText.GetText();
                        if (content.Contains(SearchQueryTextBox.ToString()))
                        {
                            filesIncludingSearch.Add($"Found in {filePath} on page {j}");
                        }
                    }
                }
                ;

                MessageBox.Show($"Sucessfully searched. Found on {String.Join(",\n", filesIncludingSearch)}");
            }
            catch (Exception)
            {
                MessageBox.Show("Failed To Search");
            }



            //for (int i = 0; i < FileList.Items.Count; i++)
            //{
            //    string fileName = FileList.Items[i].Text;
            //    PdfDocument pdfDocument = new PdfDocument(fileName);
            //    for (int j = 0; j < pdfDocument.Pages.Count; j++)
            //    {
            //        PdfPage pdfPage = pdfDocument.Pages[j];
            //        //string content;
            //        string pdfText = pdfPage.ToString();

            //        var content = new PdfToText().Search(SearchQueryTextBox.Text, false, false);
            //        if (content.ToString().Contains(SearchQueryTextBox.ToString()))
            //        {
            //            filesIncludingSearch.Add($"Found in {fileName} on page {j}");
            //        }
            //    }
            //}
        }
Exemple #2
0
        public EditMembersDialog()
        {
            InitializeComponent();

            ViewModel = new EditMembersDialogViewModel();

            this.OneWayBind(ViewModel, vm => vm.Group, v => v.TitleTextBlock.Text, group => group != null ? $"Edit {group.Principal.Name}'s Members" : "");

            this.WhenActivated(d =>
            {
                this.Bind(ViewModel, vm => vm.SearchQuery, v => v.SearchQueryTextBox.Text).DisposeWith(d);
                this.OneWayBind(ViewModel, vm => vm.SearchResults, v => v.SearchResultsListView.ItemsSource).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.SelectedSearchResult, v => v.SearchResultsListView.SelectedItem).DisposeWith(d);
                this.OneWayBind(ViewModel, vm => vm.GroupMembers, v => v.GroupMembersListView.ItemsSource).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.SelectedGroupMember, v => v.GroupMembersListView.SelectedItem).DisposeWith(d);

                SearchQueryTextBox.Focus();
                ViewModel
                .WhenAnyValue(vm => vm.Group)
                .WhereNotNull()
                .SubscribeOnDispatcher()
                .ToSignal()
                .InvokeCommand(ViewModel.GetGroupMembers)
                .DisposeWith(d);
                Observable.Merge(
                    SearchQueryTextBox.Events()
                    .KeyDown
                    .Where(args => args.Key == Key.Enter)
                    .Select(_ => ViewModel.SearchQuery),
                    ViewModel
                    .WhenAnyValue(vm => vm.SearchQuery)
                    .Throttle(TimeSpan.FromSeconds(1)))
                .Where(searchQuery => searchQuery.HasValue(3))
                .DistinctUntilChanged()
                .SubscribeOnDispatcher()
                .ToSignal()
                .InvokeCommand(ViewModel.Search)
                .DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.AddToGroup, v => v.AddMenuItem).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.OpenSearchResult, v => v.OpenSearchResultMenuItem).DisposeWith(d);
                _searchResultsListViewItemDoubleClick.ToEventCommandSignal().InvokeCommand(ViewModel.AddToGroup).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.RemoveFromGroup, v => v.RemoveMenuItem).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.OpenGroupMember, v => v.OpenGroupMemberMenuItem).DisposeWith(d);
                _groupMembersListViewItemDoubleClick.ToEventCommandSignal().InvokeCommand(ViewModel.RemoveFromGroup).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.Save, v => v.SaveButton).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.Cancel, v => v.CancelButton).DisposeWith(d);
                ViewModel
                .Messages
                .RegisterMessageHandler(ContainerGrid)
                .DisposeWith(d);
            });
        }
Exemple #3
0
        private void InitializeComponent()
        {
            _searchQueryLabel              = new Label();
            _downloadPathLabel             = new Label();
            _searchQueryTextBox            = new SearchQueryTextBox();
            _downloadPathTextBox           = new DerpiAdvancedPathTextBox();
            _downloadProgressBar           = new ProgressBar();
            _logRichTextBox                = new LoggerRichTextBox();
            _startDownloadButton           = new Button();
            _removeOrRestartDownloadButton = new Button();
            _pauseResumeButton             = new Button();
            _downloadValueLabel            = new CurrentMaxValueLabel();
            _helpToolTip = new HelpToolTip();
            SuspendLayout();

            _searchQueryLabel.Location  = new Point(2, -3);
            _searchQueryLabel.Size      = new Size(200, 20);
            _searchQueryLabel.AutoSize  = false;
            _searchQueryLabel.TextAlign = ContentAlignment.MiddleLeft;

            _downloadPathLabel.Location  = new Point(2, 40);
            _downloadPathLabel.Size      = new Size(200, 20);
            _downloadPathLabel.AutoSize  = false;
            _downloadPathLabel.TextAlign = ContentAlignment.MiddleLeft;

            _searchQueryTextBox.Location     = new Point(5, 18);
            _searchQueryTextBox.Size         = new Size(330, 22);
            _searchQueryTextBox.Multiline    = false;
            _searchQueryTextBox.TextAlign    = HorizontalAlignment.Left;
            _searchQueryTextBox.AutoSize     = false;
            _searchQueryTextBox.TextChanged += (sender, args) => OnTextChanged();

            _downloadPathTextBox.Location = new Point(3, 60);
            _downloadPathTextBox.Size     = new Size(332, 22);
            _downloadPathTextBox.AutoSize = false;
            _downloadPathTextBox.PathType = PathType.File;
            _downloadPathTextBox.UpdateAvailableFormatingParts(typeof(Json.Image));
            _downloadPathTextBox.TextChanged      += (sender, args) => OnTextChanged();
            _downloadPathTextBox.Text              = Globals.CurrentDownloadPath;
            _downloadPathTextBox.PathBeenSelected += str => _downloadPathTextBox.Text = Path.Combine(str, Globals.CurrentDownloadFileName.GetValue());

            _startDownloadButton.Location  = new Point(3, 90);
            _startDownloadButton.Size      = new Size(302, 25);
            _startDownloadButton.TextAlign = ContentAlignment.MiddleCenter;
            _startDownloadButton.Click    += OnStartDownloadButton_Click;

            _pauseResumeButton.Location  = new Point(_startDownloadButton.Location.X, _startDownloadButton.Location.Y);
            _pauseResumeButton.Size      = new Size(_startDownloadButton.Size.Width, _startDownloadButton.Size.Height);
            _pauseResumeButton.TextAlign = ContentAlignment.MiddleCenter;
            _pauseResumeButton.Visible   = false;
            _pauseResumeButton.Enabled   = false;
            _pauseResumeButton.Click    += OnPauseResumeButton_Click;

            _removeOrRestartDownloadButton.Location = new Point(304, 90);
            _removeOrRestartDownloadButton.Size     = new Size(30, 30);
            _removeOrRestartDownloadButton.Click   += OnRemoveOrRestartDownloadButtonClick;

            _logRichTextBox.Size        = new Size(200, 75);
            _logRichTextBox.Location    = new Point(340, 15);
            _logRichTextBox.Font        = new Font(Font.Name, Font.Size - 1);
            _logRichTextBox.BorderStyle = BorderStyle.Fixed3D;
            _logRichTextBox.Reversed    = false;

            _downloadProgressBar.Size     = new Size(_startDownloadButton.Size.Width - 3, 5);
            _downloadProgressBar.Location = new Point(5, 115);
            _downloadProgressBar.Style    = ProgressBarStyle.Continuous;

            _downloadValueLabel.Size                   = new Size(_logRichTextBox.Size.Width, 30);
            _downloadValueLabel.Location               = new Point(_logRichTextBox.Location.X, _logRichTextBox.Location.Y + _logRichTextBox.Size.Height);
            _downloadValueLabel.AutoSize               = false;
            _downloadValueLabel.Visible                = false;
            _downloadValueLabel.TextAlign              = ContentAlignment.MiddleLeft;
            _downloadValueLabel.Font                   = new Font(Font.Name, Font.Size + 3);
            _downloadValueLabel.DisplayType            = MathUtils.DisplayType.ValueAndPercent;
            _downloadValueLabel.PercentFractionalCount = 2;

            Controls.Add(_searchQueryLabel);
            Controls.Add(_downloadPathLabel);
            Controls.Add(_searchQueryTextBox);
            Controls.Add(_downloadPathTextBox);
            Controls.Add(_startDownloadButton);
            Controls.Add(_removeOrRestartDownloadButton);
            Controls.Add(_pauseResumeButton);
            Controls.Add(_logRichTextBox);
            Controls.Add(_downloadValueLabel);
            Controls.Add(_downloadProgressBar);
            AcceptButton            = _startDownloadButton;
            Globals.APIKey.Changed += OnTextChanged;
            ResumeLayout();
        }
Exemple #4
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            BindingExpression be = SearchQueryTextBox.GetBindingExpression(TextBox.TextProperty);

            be.UpdateSource();
        }
Exemple #5
0
        public MainWindow()
        {
            Navigation.NavigationService.Init(this);

            InitializeComponent();

            ViewModel = new MainWindowViewModel();

            this.Events()
            .Activated
            .Subscribe(_ => SearchQueryTextBox.Focus());

            this.WhenActivated(d =>
            {
                MainGrid.IsEnabled            = ADFacade.IsInDomain();
                NoDomainStackPanel.Visibility = ADFacade.IsInDomain() ? Visibility.Collapsed : Visibility.Visible;

                if (ADFacade.IsInDomain())
                {
                    this.Bind(ViewModel, vm => vm.SearchQuery, v => v.SearchQueryTextBox.Text).DisposeWith(d);
                    this.OneWayBind(ViewModel, vm => vm.History, v => v.HistoryButtonContextMenu.ItemsSource).DisposeWith(d);
                    this.OneWayBind(ViewModel, vm => vm.SearchResults, v => v.SearchResultsDataGrid.ItemsSource).DisposeWith(d);
                    this.Bind(ViewModel, vm => vm.SelectedSearchResult, v => v.SearchResultsDataGrid.SelectedItem).DisposeWith(d);
                    this.OneWayBind(ViewModel, vm => vm.IsNoResults, v => v.NoResultsTextBlock.Visibility).DisposeWith(d);
                    this.OneWayBind(ViewModel, vm => vm.SearchResults.Count, v => v.SearchResultsCountTextBox.Text, count => $"{count} {(count == 1 ? "result" : "results")}").DisposeWith(d);
                    this.OneWayBind(ViewModel, vm => vm.Domain, v => v.DomainTextBlock.Text).DisposeWith(d);

                    _openSearchResultInvokes = new Subject <Unit>().DisposeWith(d);
                    _openSearchResultInvokes.InvokeCommand(ViewModel.Open);

                    this.BindCommand(ViewModel, vm => vm.Paste, v => v.PasteButton).DisposeWith(d);
                    Observable.Merge(
                        SearchQueryTextBox.Events()
                        .KeyDown
                        .Where(args => args.Key == Key.Enter)
                        .Select(_ => ViewModel.SearchQuery),
                        ViewModel
                        .Paste
                        .Select(_ => ViewModel.SearchQuery),
                        ViewModel
                        .WhenAnyValue(vm => vm.SearchQuery)
                        .Where(searchQuery => searchQuery.HasValue(3) && !int.TryParse(searchQuery.First().ToString(), out int i))
                        .Throttle(TimeSpan.FromSeconds(1)))
                    .DistinctUntilChanged()
                    .ToSignal()
                    .ObserveOnDispatcher()
                    .InvokeCommand(ViewModel.Search)
                    .DisposeWith(d);
                    Observable.FromEventPattern(HistoryButton, nameof(Button.Click))
                    .Subscribe(e =>
                    {
                        HistoryButtonContextMenu.PlacementTarget = e.Sender as Button;
                        HistoryButtonContextMenu.IsOpen          = true;
                    })
                    .DisposeWith(d);
                    this.BindCommand(ViewModel, vm => vm.OpenSettings, v => v.SettingsButton).DisposeWith(d);
                    this.Events()
                    .Closed
                    .Subscribe(_ => Application.Current.Shutdown())
                    .DisposeWith(d);
                    SearchQueryTextBox.Events().GotFocus
                    .Subscribe(_ => SearchQueryTextBox.SelectAll())
                    .DisposeWith(d);
                    SearchQueryTextBox.Events().KeyUp
                    .Where(args => args.Key == Key.Down && SearchResultsDataGrid.Items.Count > 0)
                    .Subscribe(_ => { SearchResultsDataGrid.SelectedIndex = 0; (SearchResultsDataGrid.ItemContainerGenerator.ContainerFromIndex(0) as DataGridRow)?.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); })
                    .DisposeWith(d);
                    SearchResultsDataGrid.Events().PreviewKeyDown
                    .Where(args => args.Key == Key.Up && SearchResultsDataGrid.SelectedIndex == 0)
                    .Do(args => args.Handled = true)
                    .Subscribe(_ => Keyboard.Focus(SearchQueryTextBox))
                    .DisposeWith(d);
                    this.Events().KeyDown
                    .Where(args => args.Key == Key.F3)
                    .Subscribe(_ => Keyboard.Focus(SearchQueryTextBox))
                    .DisposeWith(d);
                }
            });
        }
Exemple #6
0
 void Src_Loaded(object sender, RoutedEventArgs e)
 {
     SearchQueryTextBox.Focus();
 }
        private void InitializeComponent()
        {
            _searchQueryLabel          = new Label();
            _downloadPathLabel         = new Label();
            _searchQueryTextBox        = new SearchQueryTextBox();
            _downloadPathTextBox       = new DerpiAdvancedPathTextBox();
            _queueAutoDownloadCheckBox = new CheckBox();
            _addTaskButton             = new Button();
            _helpToolTip = new HelpToolTip();
            SuspendLayout();

            _searchQueryLabel.Location  = new Point(2, 0);
            _searchQueryLabel.Size      = new Size(200, 20);
            _searchQueryLabel.AutoSize  = false;
            _searchQueryLabel.TextAlign = ContentAlignment.MiddleLeft;

            _downloadPathLabel.Location  = new Point(2, 45);
            _downloadPathLabel.Size      = new Size(200, 20);
            _downloadPathLabel.AutoSize  = false;
            _downloadPathLabel.TextAlign = ContentAlignment.MiddleLeft;

            _searchQueryTextBox.Location     = new Point(5, 20);
            _searchQueryTextBox.Size         = new Size(390, 25);
            _searchQueryTextBox.Multiline    = false;
            _searchQueryTextBox.TextAlign    = HorizontalAlignment.Left;
            _searchQueryTextBox.AutoSize     = false;
            _searchQueryTextBox.TextChanged += (sender, args) => OnTextChanged();

            _downloadPathTextBox.Location = new Point(3, 65);
            _downloadPathTextBox.Size     = new Size(393, 25);
            _downloadPathTextBox.PathType = PathType.File;
            _downloadPathTextBox.UpdateAvailableFormatingParts(typeof(Json.Image));
            _downloadPathTextBox.TextChanged      += (sender, args) => OnTextChanged();
            _downloadPathTextBox.Text              = Globals.CurrentDownloadPath;
            _downloadPathTextBox.PathBeenSelected += str => _downloadPathTextBox.Text = Path.Combine(str, Globals.CurrentDownloadFileName.GetValue());

            _queueAutoDownloadCheckBox.Location    = new Point(5, 95);
            _queueAutoDownloadCheckBox.MinimumSize = new Size(0, 20);
            _queueAutoDownloadCheckBox.AutoSize    = true;
            _queueAutoDownloadCheckBox.Checked     = Globals.QueueAutoDownload.GetValue();

            _addTaskButton.Location = new Point(5, 115);
            _addTaskButton.Size     = new Size(390, 30);
            _addTaskButton.Click   += OnAddTaskButton_Click;

            MinimizeBox         = false;
            MaximizeBox         = false;
            ShowInTaskbar       = false;
            AcceptButton        = _addTaskButton;
            AutoScaleDimensions = new SizeF(7F, 15F);
            ClientSize          = new Size(400, 150);
            AutoScaleMode       = AutoScaleMode.Font;
            FormBorderStyle     = FormBorderStyle.FixedSingle;
            Icon = ImageUtils.IconFromImage(Images.Lineal.Download);
            Controls.Add(_searchQueryLabel);
            Controls.Add(_downloadPathLabel);
            Controls.Add(_searchQueryTextBox);
            Controls.Add(_downloadPathTextBox);
            Controls.Add(_queueAutoDownloadCheckBox);
            Controls.Add(_addTaskButton);
            ResumeLayout();
        }