Skip to content

Commit

Permalink
use default ByteToHex conversion to optimized refresh
Browse files Browse the repository at this point in the history
delete the support of VerticalScrollBarVisibility
  • Loading branch information
Derek Tremblay committed Aug 27, 2017
1 parent 9458893 commit a6dfbbe
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 67 deletions.
2 changes: 1 addition & 1 deletion WPFHexaEditor.Control/Core/Bytes/ByteConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static byte[] HexToByte(string hex)

public static bool HexToByte(string hex, out byte b)
{
return byte.TryParse(hex, System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture, out b);
return byte.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out b);
}

public static long HexLiteralToLong(string hex)
Expand Down
48 changes: 6 additions & 42 deletions WPFHexaEditor.Control/HexaEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ public HexaEditor()
InitializeComponent();

//Load default build-in TBL
TypeOfCharacterTable = CharacterTableType.TBLFile;
LoadDefaultTBL(DefaultCharacterTableType.ASCII);
//TypeOfCharacterTable = CharacterTableType.TBLFile;
//LoadDefaultTBL(DefaultCharacterTableType.ASCII);

//Refresh view
UpdateVerticalScroll();
RefreshView(true);

DataContext = this;
Expand Down Expand Up @@ -1244,8 +1245,6 @@ private void Control_MoveNext(object sender, EventArgs e)
//Call moveright event
Control_MoveRight(sender, new EventArgs());
}


#endregion Selection Property/Methods/Event

#region Copy/Paste/Cut Methods
Expand Down Expand Up @@ -1567,41 +1566,7 @@ private static void StringDataVisibility_ValidateValue(DependencyObject d, Depen
}
}
}

/// <summary>
/// Set or Get value for change visibility of vertical scroll bar
/// </summary>
public Visibility VerticalScrollBarVisibility
{
get { return (Visibility)GetValue(VerticalScrollBarVisibilityProperty); }
set { SetValue(VerticalScrollBarVisibilityProperty, value); }
}

public static readonly DependencyProperty VerticalScrollBarVisibilityProperty =
DependencyProperty.Register("VerticalScrollBarVisibility", typeof(Visibility), typeof(HexaEditor),
new FrameworkPropertyMetadata(Visibility.Visible,
new PropertyChangedCallback(VerticalScrollBarVisibility_ValueChanged),
new CoerceValueCallback(Visibility_CoerceValue)));

private static void VerticalScrollBarVisibility_ValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is HexaEditor ctrl)
{
Visibility value = (Visibility)e.NewValue;

switch (value)
{
case Visibility.Visible:
ctrl.VerticalScrollBar.Visibility = Visibility.Visible;
break;

case Visibility.Collapsed:
ctrl.VerticalScrollBar.Visibility = Visibility.Collapsed;
break;
}
}
}


/// <summary>
/// Set or Get value for change visibility of status bar
/// </summary>
Expand Down Expand Up @@ -1801,11 +1766,11 @@ public void CloseProvider()
UnSelectAll();
RefreshView();
UpdateHexHeader();
UpdateVerticalScroll();
}

/// <summary>
/// Save to the current stream
/// TODO: Add save as another stream...
/// Save to the current stream/file
/// </summary>
public void SubmitChanges()
{
Expand All @@ -1816,7 +1781,6 @@ public void SubmitChanges()

/// <summary>
/// Save as to another file
/// TODO: Add save as another stream...
/// </summary>
public void SubmitChanges(string newfilename, bool overwrite = false)
{
Expand Down
6 changes: 1 addition & 5 deletions WPFHexaEditor.Control/WPFHexaEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
Expand Down Expand Up @@ -155,7 +152,6 @@
<LastGenOutput>Resources.fr-CA.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -191,4 +187,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
4 changes: 0 additions & 4 deletions WPFHexaEditor.Control/packages.config

This file was deleted.

6 changes: 1 addition & 5 deletions WPFHexaEditorExample/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,10 @@
<MenuItem x:Name="ShowHeaderMenu" Header="Header visibility" Click="ShowHeaderMenu_Click"
IsCheckable="True"
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=HeaderVisibility, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />

<MenuItem x:Name="ShowScrollMenu" Header="Scroll visibility" Click="ShowScrollMenu_Click"
IsCheckable="True"
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=ScrollVisibility, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
</MenuItem>
</Menu>

<Control:HexaEditor x:Name="HexEdit" Width="Auto" Height="Auto" Margin="2" AllowByteCount="False"/>
<Control:HexaEditor x:Name="HexEdit" Width="Auto" Height="Auto" Margin="2" AllowByteCount="False" />
</DockPanel>
</Grid>
</Window>
10 changes: 0 additions & 10 deletions WPFHexaEditorExample/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ private void UpdateSetting(SettingEnum setting)

Settings.Default.HeaderVisibility = HexEdit.HeaderVisibility == Visibility.Visible;
break;

case SettingEnum.ScrollVisibility:
if (!Settings.Default.ScrollVisibility)
HexEdit.VerticalScrollBarVisibility = Visibility.Collapsed;
else
HexEdit.VerticalScrollBarVisibility = Visibility.Visible;

Settings.Default.ScrollVisibility = HexEdit.VerticalScrollBarVisibility == Visibility.Visible;
break;

case SettingEnum.ReadOnly:
HexEdit.ReadOnlyMode = Settings.Default.ReadOnly;

Expand Down

0 comments on commit a6dfbbe

Please sign in to comment.