<commit_before>﻿Imports Microsoft.Win32
Imports System.IO
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Input
Imports WpfHexaEditor.Core
Imports WpfHexaEditor.Core.Bytes
Imports WpfHexaEditor.Core.CharacterTable
Imports WpfHexaEditor.Dialog
Imports WpfHexEditor.Sample.VB.MySettings

Namespace WPFHexaEditorExample
    Partial Public Class MainWindow
        Private Enum SettingEnum
            HeaderVisibility
            [ReadOnly]
            ScrollVisibility
            StatusBarVisibility
        End Enum

        Public Sub New()
            InitializeComponent()
            UpdateAllSettings()
        End Sub

        Private Sub OpenMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim fileDialog = New OpenFileDialog()

            If fileDialog.ShowDialog() IsNot Nothing AndAlso File.Exists(fileDialog.FileName) Then
                Windows.Application.Current.MainWindow.Cursor = Cursors.Wait
                HexEdit.FileName = fileDialog.FileName
                Windows.Application.Current.MainWindow.Cursor = Nothing
            End If
        End Sub

        Private Sub SaveMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Application.Current.MainWindow.Cursor = Cursors.Wait
            HexEdit.SubmitChanges()
            Application.Current.MainWindow.Cursor = Nothing
        End Sub

        Private Sub CloseFileMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.CloseProvider()
        End Sub

        Private Sub SetReadOnlyMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            UpdateSetting(SettingEnum.[ReadOnly])
        End Sub

        Private Sub ShowHeaderMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            UpdateSetting(SettingEnum.HeaderVisibility)
        End Sub

        Private Sub StatusBarVisibility_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            UpdateSetting(SettingEnum.StatusBarVisibility)
        End Sub

        Private Sub UpdateSetting(ByVal setting As SettingEnum)
            Select Case setting
                Case SettingEnum.HeaderVisibility
                    HexEdit.HeaderVisibility = If(Not [Default].HeaderVisibility, Visibility.Collapsed, Visibility.Visible)
                    [Default].HeaderVisibility = HexEdit.HeaderVisibility = Visibility.Visible
                Case SettingEnum.[ReadOnly]
                    HexEdit.ReadOnlyMode = [Default].ReadOnlyS
                    HexEdit.ClearAllChange()
                    HexEdit.RefreshView()
                Case SettingEnum.StatusBarVisibility
                    HexEdit.StatusBarVisibility = If(Not [Default].StatusBarVisibility, Visibility.Collapsed, Visibility.Visible)
                    [Default].StatusBarVisibility = HexEdit.StatusBarVisibility = Visibility.Visible
            End Select
        End Sub

        Private Sub UpdateAllSettings()
            UpdateSetting(SettingEnum.HeaderVisibility)
            UpdateSetting(SettingEnum.[ReadOnly])
            UpdateSetting(SettingEnum.ScrollVisibility)
        End Sub

        Private Sub Window_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
            HexEdit.CloseProvider()
            [Default].Save()
        End Sub

        Private Sub ExitMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Close()
        End Sub

        Private Sub CopyHexaMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.CopyToClipboard(CopyPasteMode.HexaString)
        End Sub

        Private Sub CopyStringMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.CopyToClipboard()
        End Sub

        Private Sub DeleteSelectionMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.DeleteSelection()
        End Sub

        Private Sub GOPosition_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim position = Nothing

            If Long.TryParse(PositionText.Text, position) Then
                HexEdit.SetPosition(position, 1)
            Else
                MessageBox.Show("Enter long value.")
            End If

            ViewMenu.IsSubmenuOpen = False
        End Sub

        Private Sub PositionText_TextChanged(ByVal sender As Object, ByVal e As TextChangedEventArgs)
            Dim __ = Nothing
            GoPositionButton.IsEnabled = Long.TryParse(PositionText.Text, __)
        End Sub

        Private Sub UndoMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.Undo()
        End Sub

        Private Sub RedoMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.Redo()
        End Sub

        Private Sub SetBookMarkButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.SetBookMark()
        End Sub

        Private Sub DeleteBookmark_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.ClearScrollMarker(ScrollMarker.Bookmark)
        End Sub

        Private Sub FindText_TextChanged(ByVal sender As Object, ByVal e As TextChangedEventArgs)
        End Sub

        Private Sub FindFirstButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        End Sub

        Private Sub FindPreviousButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        End Sub

        Private Sub FindAllSelection_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.FindAllSelection(True)
        End Sub

        Private Sub SelectAllButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.SelectAll()
        End Sub

        Private Sub FindNextButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        End Sub

        Private Sub CTableASCIIButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.TypeOfCharacterTable = CharacterTableType.Ascii
            CTableAsciiButton.IsChecked = True
            CTableTblButton.IsChecked = False
            CTableTblDefaultAsciiButton.IsChecked = False
        End Sub

        Private Sub CTableTBLButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim fileDialog = New OpenFileDialog()

            If fileDialog.ShowDialog() IsNot Nothing Then

                If File.Exists(fileDialog.FileName) Then
                    Application.Current.MainWindow.Cursor = Cursors.Wait
                    HexEdit.LoadTblFile(fileDialog.FileName)
                    HexEdit.TypeOfCharacterTable = CharacterTableType.TblFile
                    CTableAsciiButton.IsChecked = False
                    CTableTblButton.IsChecked = True
                    CTableTblDefaultAsciiButton.IsChecked = False
                    Application.Current.MainWindow.Cursor = Nothing
                End If
            End If
        End Sub

        Private Sub CTableTBLDefaultASCIIButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Application.Current.MainWindow.Cursor = Cursors.Wait
            HexEdit.TypeOfCharacterTable = CharacterTableType.TblFile<commit_msg>Deleted somes Unused event in VB sample project<commit_after>﻿Imports Microsoft.Win32
Imports System.IO
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Input
Imports WpfHexaEditor.Core
Imports WpfHexaEditor.Core.Bytes
Imports WpfHexaEditor.Core.CharacterTable
Imports WpfHexaEditor.Dialog
Imports WpfHexEditor.Sample.VB.MySettings

Namespace WPFHexaEditorExample
    Partial Public Class MainWindow
        Private Enum SettingEnum
            HeaderVisibility
            [ReadOnly]
            ScrollVisibility
            StatusBarVisibility
        End Enum

        Public Sub New()
            InitializeComponent()
            UpdateAllSettings()
        End Sub

        Private Sub OpenMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim fileDialog = New OpenFileDialog()

            If fileDialog.ShowDialog() IsNot Nothing AndAlso File.Exists(fileDialog.FileName) Then
                Windows.Application.Current.MainWindow.Cursor = Cursors.Wait
                HexEdit.FileName = fileDialog.FileName
                Windows.Application.Current.MainWindow.Cursor = Nothing
            End If
        End Sub

        Private Sub SaveMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Application.Current.MainWindow.Cursor = Cursors.Wait
            HexEdit.SubmitChanges()
            Application.Current.MainWindow.Cursor = Nothing
        End Sub

        Private Sub CloseFileMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.CloseProvider()
        End Sub

        Private Sub SetReadOnlyMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            UpdateSetting(SettingEnum.[ReadOnly])
        End Sub

        Private Sub ShowHeaderMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            UpdateSetting(SettingEnum.HeaderVisibility)
        End Sub

        Private Sub StatusBarVisibility_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            UpdateSetting(SettingEnum.StatusBarVisibility)
        End Sub

        Private Sub UpdateSetting(ByVal setting As SettingEnum)
            Select Case setting
                Case SettingEnum.HeaderVisibility
                    HexEdit.HeaderVisibility = If(Not [Default].HeaderVisibility, Visibility.Collapsed, Visibility.Visible)
                    [Default].HeaderVisibility = HexEdit.HeaderVisibility = Visibility.Visible
                Case SettingEnum.[ReadOnly]
                    HexEdit.ReadOnlyMode = [Default].ReadOnlyS
                    HexEdit.ClearAllChange()
                    HexEdit.RefreshView()
                Case SettingEnum.StatusBarVisibility
                    HexEdit.StatusBarVisibility = If(Not [Default].StatusBarVisibility, Visibility.Collapsed, Visibility.Visible)
                    [Default].StatusBarVisibility = HexEdit.StatusBarVisibility = Visibility.Visible
            End Select
        End Sub

        Private Sub UpdateAllSettings()
            UpdateSetting(SettingEnum.HeaderVisibility)
            UpdateSetting(SettingEnum.[ReadOnly])
            UpdateSetting(SettingEnum.ScrollVisibility)
        End Sub

        Private Sub Window_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
            HexEdit.CloseProvider()
            [Default].Save()
        End Sub

        Private Sub ExitMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Close()
        End Sub

        Private Sub CopyHexaMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.CopyToClipboard(CopyPasteMode.HexaString)
        End Sub

        Private Sub CopyStringMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.CopyToClipboard()
        End Sub

        Private Sub DeleteSelectionMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.DeleteSelection()
        End Sub

        Private Sub GOPosition_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim position = Nothing

            If Long.TryParse(PositionText.Text, position) Then
                HexEdit.SetPosition(position, 1)
            Else
                MessageBox.Show("Enter long value.")
            End If

            ViewMenu.IsSubmenuOpen = False
        End Sub

        Private Sub PositionText_TextChanged(ByVal sender As Object, ByVal e As TextChangedEventArgs)
            Dim __ = Nothing
            GoPositionButton.IsEnabled = Long.TryParse(PositionText.Text, __)
        End Sub

        Private Sub UndoMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.Undo()
        End Sub

        Private Sub RedoMenu_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.Redo()
        End Sub

        Private Sub SetBookMarkButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.SetBookMark()
        End Sub

        Private Sub DeleteBookmark_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.ClearScrollMarker(ScrollMarker.Bookmark)
        End Sub

        Private Sub FindAllSelection_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.FindAllSelection(True)
        End Sub

        Private Sub SelectAllButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.SelectAll()
        End Sub

        Private Sub CTableASCIIButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            HexEdit.TypeOfCharacterTable = CharacterTableType.Ascii
            CTableAsciiButton.IsChecked = True
            CTableTblButton.IsChecked = False
            CTableTblDefaultAsciiButton.IsChecked = False
        End Sub

        Private Sub CTableTBLButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim fileDialog = New OpenFileDialog()

            If fileDialog.ShowDialog() IsNot Nothing Then

                If File.Exists(fileDialog.FileName) Then
                    Application.Current.MainWindow.Cursor = Cursors.Wait
                    HexEdit.LoadTblFile(fileDialog.FileName)
                    HexEdit.TypeOfCharacterTable = CharacterTableType.TblFile
                    CTableAsciiButton.IsChecked = False
                    CTableTblButton.IsChecked = True
                    CTableTblDefaultAsciiButton.IsChecked = False
                    Application.Current.MainWindow.Cursor = Nothing
                End If
            End If
        End Sub

        Private Sub CTableTBLDefaultASCIIButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Application.Current.MainWindow.Cursor = Cursors.Wait
            HexEdit.TypeOfCharacterTable = CharacterTableType.TblFile
{'fraction_non_alphanumeric': 0.04741563434429731, 'fraction_numerical': 0.00042716787697565144, 'mean_word_length': 2.289695550351288, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6984276', 'n_tokens_mistral': 3566, 'n_tokens_neox': 3352, 'n_words': 960}